Skip to content

Commit 645e845

Browse files
feat: Add stateful disk support (#90)
* Added: stateful configuration * Added: var udpate * Added: var udpate * Updated: stateful_disk variable, autogen docs
1 parent e423c27 commit 645e845

File tree

4 files changed

+55
-14
lines changed

4 files changed

+55
-14
lines changed

autogen/main.tf.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ resource "google_compute_region_instance_group_manager" "{{ module_name }}" {
7979
}
8080
}
8181

82+
dynamic "stateful_disk" {
83+
for_each = var.stateful_disks
84+
content {
85+
device_name = stateful_disk.value.device_name
86+
delete_rule = lookup(stateful_disk.value, "delete_rule", null)
87+
}
88+
}
89+
8290
distribution_policy_zones = local.distribution_policy_zones
8391
dynamic "update_policy" {
8492
for_each = var.update_policy

autogen/variables.tf.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ variable "distribution_policy_zones" {
6767
default = []
6868
}
6969

70+
#################
71+
# Stateful disks
72+
#################
73+
variable "stateful_disks" {
74+
description = "Disks created on the instances that will be preserved on instance delete. https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-disks-in-migs"
75+
type = list(object({
76+
device_name = string
77+
delete_rule = string
78+
}))
79+
default = []
80+
}
81+
7082
#################
7183
# Rolling Update
7284
#################

modules/mig/main.tf

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,26 @@ resource "google_compute_region_instance_group_manager" "mig" {
6363
}
6464
}
6565

66+
dynamic "stateful_disk" {
67+
for_each = var.stateful_disks
68+
content {
69+
device_name = stateful_disk.value.device_name
70+
delete_rule = lookup(stateful_disk.value, "delete_rule", null)
71+
}
72+
}
73+
6674
distribution_policy_zones = local.distribution_policy_zones
6775
dynamic "update_policy" {
6876
for_each = var.update_policy
6977
content {
70-
max_surge_fixed = lookup(update_policy.value, "max_surge_fixed", null)
71-
max_surge_percent = lookup(update_policy.value, "max_surge_percent", null)
72-
max_unavailable_fixed = lookup(update_policy.value, "max_unavailable_fixed", null)
73-
max_unavailable_percent = lookup(update_policy.value, "max_unavailable_percent", null)
74-
min_ready_sec = lookup(update_policy.value, "min_ready_sec", null)
75-
minimal_action = update_policy.value.minimal_action
76-
type = update_policy.value.type
78+
instance_redistribution_type = lookup(update_policy.value, "instance_redistribution_type", null)
79+
max_surge_fixed = lookup(update_policy.value, "max_surge_fixed", null)
80+
max_surge_percent = lookup(update_policy.value, "max_surge_percent", null)
81+
max_unavailable_fixed = lookup(update_policy.value, "max_unavailable_fixed", null)
82+
max_unavailable_percent = lookup(update_policy.value, "max_unavailable_percent", null)
83+
min_ready_sec = lookup(update_policy.value, "min_ready_sec", null)
84+
minimal_action = update_policy.value.minimal_action
85+
type = update_policy.value.type
7786
}
7887
}
7988

modules/mig/variables.tf

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,32 @@ variable "distribution_policy_zones" {
5252
default = []
5353
}
5454

55+
#################
56+
# Stateful disks
57+
#################
58+
variable "stateful_disks" {
59+
description = "Disks created on the instances that will be preserved on instance delete. https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-disks-in-migs"
60+
type = list(object({
61+
device_name = string
62+
delete_rule = string
63+
}))
64+
default = []
65+
}
5566
#################
5667
# Rolling Update
5768
#################
5869

5970
variable "update_policy" {
6071
description = "The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager.html#rolling_update_policy"
6172
type = list(object({
62-
max_surge_fixed = number
63-
max_surge_percent = number
64-
max_unavailable_fixed = number
65-
max_unavailable_percent = number
66-
min_ready_sec = number
67-
minimal_action = string
68-
type = string
73+
max_surge_fixed = number
74+
instance_redistribution_type = string
75+
max_surge_percent = number
76+
max_unavailable_fixed = number
77+
max_unavailable_percent = number
78+
min_ready_sec = number
79+
minimal_action = string
80+
type = string
6981
}))
7082
default = []
7183
}

0 commit comments

Comments
 (0)