Skip to content

Commit

Permalink
change: MIG from Managed to Stateful with persistent disk and nics
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolnar-zscaler committed Jan 9, 2024
1 parent b22a27d commit 0c9a87c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
15 changes: 15 additions & 0 deletions modules/terraform-zscc-ccvm-gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ resource "google_compute_instance_group_manager" "cc_instance_group_manager" {
replacement_method = var.update_policy_replacement_method
}

stateful_disk {
device_name = google_compute_instance_template.cc_instance_template.disk[0].device_name
delete_rule = var.stateful_delete_rule
}

stateful_internal_ip {
interface_name = google_compute_instance_template.cc_instance_template.network_interface[0].name
delete_rule = var.stateful_delete_rule
}

stateful_internal_ip {
interface_name = google_compute_instance_template.cc_instance_template.network_interface[1].name
delete_rule = var.stateful_delete_rule
}

lifecycle {
create_before_destroy = true
}
Expand Down
12 changes: 9 additions & 3 deletions modules/terraform-zscc-ccvm-gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ variable "update_policy_type" {

variable "update_policy_replacement_method" {
type = string
description = "The instance replacement method for managed instance groups. Valid values are: RECREATE or SUBSTITUTE. If SUBSTITUTE (default), the group replaces VM instances with new instances that have randomly generated names. If RECREATE, instance names are preserved. You must also set max_unavailable_fixed or max_unavailable_percent to be greater than 0"
default = "SUBSTITUTE"
description = "The instance replacement method for managed instance groups. Valid values are: RECREATE or SUBSTITUTE. If SUBSTITUTE, the group replaces VM instances with new instances that have randomly generated names. If RECREATE, instance names are preserved. You must also set max_unavailable_fixed or max_unavailable_percent to be greater than 0"
default = "RECREATE"
validation {
condition = (
var.update_policy_replacement_method == "RECREATE" ||
Expand All @@ -111,7 +111,7 @@ variable "update_policy_replacement_method" {
variable "update_policy_max_surge_fixed" {
type = number
description = "The maximum number of instances that can be created above the specified targetSize during the update process. Conflicts with max_surge_percent. If neither is set, defaults to 1"
default = 1
default = 0
}

variable "update_max_unavailable_fixed" {
Expand All @@ -137,3 +137,9 @@ variable "base_instance_name" {
description = "The base instance name to use for instances in this group. The value must be a valid RFC1035 name. Supported characters are lowercase letters, numbers, and hyphens (-). Instances are named by appending a hyphen and a random four-character string to the base instance name"
default = [""]
}

variable "stateful_delete_rule" {
type = string
description = " A value that prescribes what should happen to the stateful disk when the VM instance is deleted. The available options are NEVER and ON_PERMANENT_INSTANCE_DELETION. NEVER - detach the disk when the VM is deleted, but do not delete the disk. ON_PERMANENT_INSTANCE_DELETION will delete the stateful disk when the VM is permanently deleted from the instance group."
default = "ON_PERMANENT_INSTANCE_DELETION"
}

0 comments on commit 0c9a87c

Please sign in to comment.