Skip to content

Commit 1d5da75

Browse files
fix: update vmss on user_data change (CLOUD-3215)
1 parent e2ee312 commit 1d5da75

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

functions.tf

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,19 @@ locals {
3232
lb_backend_pool_ids = var.create_lb ? [azurerm_lb_backend_address_pool.lb_backend_pool[0].id] : []
3333

3434
vmss_config = jsonencode({
35-
name = "${var.prefix}-${var.cluster_name}-vmss"
36-
location = data.azurerm_resource_group.rg.location
37-
zones = var.zone != null ? [var.zone] : []
38-
resource_group_name = var.rg_name
39-
sku = var.instance_type
40-
upgrade_mode = "Manual"
41-
health_probe_id = local.vmss_health_probe_id
42-
admin_username = var.vm_username
43-
ssh_public_key = local.public_ssh_key
44-
computer_name_prefix = "${var.prefix}-${var.cluster_name}-backend"
45-
custom_data = ""
35+
name = "${var.prefix}-${var.cluster_name}-vmss"
36+
location = data.azurerm_resource_group.rg.location
37+
zones = var.zone != null ? [var.zone] : []
38+
resource_group_name = var.rg_name
39+
sku = var.instance_type
40+
upgrade_mode = "Manual"
41+
health_probe_id = local.vmss_health_probe_id
42+
admin_username = var.vm_username
43+
ssh_public_key = local.public_ssh_key
44+
computer_name_prefix = "${var.prefix}-${var.cluster_name}-backend"
45+
# NOTE: as custom data (to keep it short but unique) we use the hash of the function app code + user_data input hash
46+
# this way we can detect both changes in the function app code and user input and trigger vmss update
47+
custom_data = base64encode(join("", [local.function_app_code_hash, sha256(var.user_data)]))
4648
disable_password_authentication = true
4749
proximity_placement_group_id = local.placement_group_id
4850
single_placement_group = var.vmss_single_placement_group

0 commit comments

Comments
 (0)