Skip to content

Commit 6bcad2e

Browse files
committed
updating rolling rolling_upgrade_policy and automatic_os_upgrade_policy and making them dynamic using os_upgrade_mode value for Window VM scale set.
1 parent ba86511 commit 6bcad2e

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

main.tf

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ resource "azurerm_linux_virtual_machine_scale_set" "linux_vmss" {
358358
lifecycle {
359359
ignore_changes = [
360360
tags,
361-
ip_tag,
362361
]
363362
}
364363

@@ -452,16 +451,22 @@ resource "azurerm_windows_virtual_machine_scale_set" "winsrv_vmss" {
452451
}
453452
}
454453

455-
automatic_os_upgrade_policy {
456-
disable_automatic_rollback = true
457-
enable_automatic_os_upgrade = true
454+
dynamic "automatic_os_upgrade_policy" {
455+
for_each = var.os_upgrade_mode == "Automatic" ? [1] : []
456+
content {
457+
disable_automatic_rollback = true
458+
enable_automatic_os_upgrade = true
459+
}
458460
}
459461

460-
rolling_upgrade_policy {
461-
max_batch_instance_percent = 20
462-
max_unhealthy_instance_percent = 20
463-
max_unhealthy_upgraded_instance_percent = 5
464-
pause_time_between_batches = "PT0S"
462+
dynamic "rolling_upgrade_policy" {
463+
for_each = var.os_upgrade_mode == "Automatic" ? [1] : []
464+
content {
465+
max_batch_instance_percent = var.rolling_upgrade_policy.max_batch_instance_percent
466+
max_unhealthy_instance_percent = var.rolling_upgrade_policy.max_unhealthy_instance_percent
467+
max_unhealthy_upgraded_instance_percent = var.rolling_upgrade_policy.max_unhealthy_upgraded_instance_percent
468+
pause_time_between_batches = var.rolling_upgrade_policy.pause_time_between_batches
469+
}
465470
}
466471

467472
automatic_instance_repair {

variables.tf

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ variable "lb_availability_zone" {
7373
default = "Zone-Redundant"
7474
}
7575

76+
variable "private_ip_address_allocation" {
77+
description = "The allocation method for the Private IP Address used by this Load Balancer. Possible values as Dynamic and Static."
78+
default = "Dynamic"
79+
}
80+
81+
variable "lb_private_ip_address" {
82+
description = "Private IP Address to assign to the Load Balancer."
83+
default = null
84+
}
85+
7686
variable "lb_probe_protocol" {
7787
description = "Specifies the protocol of the end point. Possible values are `Http`, `Https` or `Tcp`. If `Tcp` is specified, a received ACK is required for the probe to be successful. If `Http` is specified, a `200 OK` response from the specified `URI` is required for the probe to be successful."
7888
default = null
@@ -220,6 +230,11 @@ variable "os_upgrade_mode" {
220230
default = "Automatic"
221231
}
222232

233+
variable "vm_time_zone" {
234+
description = "Specifies the Time Zone which should be used by the Virtual Machine"
235+
default = null
236+
}
237+
223238
variable "availability_zones" {
224239
description = "A list of Availability Zones in which the Virtual Machines in this Scale Set should be created in"
225240
default = [1, 2, 3]
@@ -232,12 +247,12 @@ variable "availability_zone_balance" {
232247

233248
variable "generate_admin_ssh_key" {
234249
description = "Generates a secure private key and encodes it as PEM."
235-
default = true
250+
default = false
236251
}
237252

238253
variable "admin_ssh_key_data" {
239254
description = "specify the path to the existing ssh key to authenciate linux vm"
240-
default = ""
255+
default = null
241256
}
242257

243258
variable "custom_image" {
@@ -469,15 +484,7 @@ variable "grace_period" {
469484

470485

471486

472-
variable "private_ip_address_allocation" {
473-
description = "The allocation method for the Private IP Address used by this Load Balancer. Possible values as Dynamic and Static."
474-
default = "Dynamic"
475-
}
476487

477-
variable "lb_private_ip_address" {
478-
description = "Private IP Address to assign to the Load Balancer."
479-
default = null
480-
}
481488

482489

483490

@@ -535,11 +542,6 @@ variable "intall_iis_server_on_instances" {
535542
default = false
536543
}
537544

538-
variable "vm_time_zone" {
539-
description = "Specifies the Time Zone which should be used by the Virtual Machine"
540-
default = null
541-
}
542-
543545
variable "deploy_log_analytics_agent" {
544546
description = "Install log analytics agent to windows or linux VM scaleset instances"
545547
default = false

0 commit comments

Comments
 (0)