Skip to content

Commit 298e2b3

Browse files
committed
update to code to support rolling updates and other fixes.
1 parent 1f762a6 commit 298e2b3

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

main.tf

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ resource "azurerm_public_ip" "pip" {
6767
sku = var.public_ip_sku
6868
sku_tier = var.public_ip_sku_tier
6969
domain_name_label = var.domain_name_label
70-
availability_zone = var.public_ip_availability_zone
71-
tags = merge({ "resourcename" = lower("pip-vm-${var.vmscaleset_name}-${data.azurerm_resource_group.rg.location}-0${count.index + 1}") }, var.tags, )
70+
# availability_zone = var.public_ip_availability_zone
71+
tags = merge({ "resourcename" = lower("pip-vm-${var.vmscaleset_name}-${data.azurerm_resource_group.rg.location}-0${count.index + 1}") }, var.tags, )
7272

7373
lifecycle {
7474
ignore_changes = [
@@ -90,7 +90,6 @@ resource "azurerm_lb" "vmsslb" {
9090

9191
frontend_ip_configuration {
9292
name = var.load_balancer_type == "public" ? lower("lbext-frontend-${var.vmscaleset_name}") : lower("lbint-frontend-${var.vmscaleset_name}")
93-
availability_zone = var.lb_availability_zone
9493
public_ip_address_id = var.enable_load_balancer == true && var.load_balancer_type == "public" ? azurerm_public_ip.pip[count.index].id : null
9594
private_ip_address_allocation = var.load_balancer_type == "private" ? var.private_ip_address_allocation : null
9695
private_ip_address = var.load_balancer_type == "private" && var.private_ip_address_allocation == "Static" ? var.lb_private_ip_address : null
@@ -352,6 +351,11 @@ resource "azurerm_linux_virtual_machine_scale_set" "linux_vmss" {
352351
lifecycle {
353352
ignore_changes = [
354353
tags,
354+
automatic_instance_repair,
355+
automatic_os_upgrade_policy,
356+
rolling_upgrade_policy,
357+
instances,
358+
data_disk,
355359
]
356360
}
357361

@@ -375,7 +379,7 @@ resource "azurerm_windows_virtual_machine_scale_set" "winsrv_vmss" {
375379
custom_data = var.custom_data
376380
overprovision = var.overprovision
377381
do_not_run_extensions_on_overprovisioned_machines = var.do_not_run_extensions_on_overprovisioned_machines
378-
enable_automatic_updates = var.enable_windows_vm_automatic_updates
382+
enable_automatic_updates = var.os_upgrade_mode != "Automatic" ? var.enable_windows_vm_automatic_updates : false
379383
encryption_at_host_enabled = var.enable_encryption_at_host
380384
health_probe_id = var.enable_load_balancer ? azurerm_lb_probe.lbp[0].id : null
381385
license_type = var.license_type
@@ -509,6 +513,18 @@ resource "azurerm_windows_virtual_machine_scale_set" "winsrv_vmss" {
509513
}
510514
}
511515

516+
lifecycle {
517+
ignore_changes = [
518+
tags,
519+
automatic_instance_repair,
520+
automatic_os_upgrade_policy,
521+
rolling_upgrade_policy,
522+
instances,
523+
winrm_listener,
524+
additional_unattend_content,
525+
data_disk,
526+
]
527+
}
512528
# As per the recomendation by Terraform documentation
513529
depends_on = [azurerm_lb_rule.lbrule]
514530
}

variables.tf

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ variable "load_balancer_sku" {
6767
description = "The SKU of the Azure Load Balancer. Accepted values are Basic and Standard."
6868
default = "Standard"
6969
}
70-
71-
variable "lb_availability_zone" {
72-
description = "A list of Availability Zones which the Load Balancer's IP Addresses should be created in. Possible values are `Zone-Redundant`, `1`, `2`, `3`, and `No-Zone`. Availability Zone can only be updated whenever the name of the front end ip configuration changes"
73-
default = "Zone-Redundant"
74-
}
75-
7670
variable "private_ip_address_allocation" {
7771
description = "The allocation method for the Private IP Address used by this Load Balancer. Possible values as Dynamic and Static."
7872
default = "Dynamic"
@@ -237,12 +231,12 @@ variable "vm_time_zone" {
237231

238232
variable "availability_zones" {
239233
description = "A list of Availability Zones in which the Virtual Machines in this Scale Set should be created in"
240-
default = [1, 2, 3]
234+
default = null #[1, 2, 3]
241235
}
242236

243237
variable "availability_zone_balance" {
244238
description = "Should the Virtual Machines in this Scale Set be strictly evenly distributed across Availability Zones?"
245-
default = true
239+
default = false
246240
}
247241

248242
variable "generate_admin_ssh_key" {

0 commit comments

Comments
 (0)