From 1e55d5e8ba45e3b27f65b3822f9da6d8a1bf6e22 Mon Sep 17 00:00:00 2001 From: Rauny Date: Tue, 20 Feb 2024 11:03:04 +0100 Subject: [PATCH 1/3] feat: mig labels & most disruptive update policy action update --- autogen/main.tf.tmpl | 23 +++++++------ autogen/variables.tf.tmpl | 25 +++++++++------ metadata.yaml | 2 +- modules/compute_disk_snapshot/metadata.yaml | 8 +---- modules/compute_instance/metadata.yaml | 7 +--- modules/instance_template/metadata.yaml | 12 +------ modules/mig/README.md | 3 +- modules/mig/main.tf | 23 +++++++------ modules/mig/metadata.yaml | 30 ++++++++--------- modules/mig/variables.tf | 25 +++++++++------ modules/mig_with_percent/README.md | 3 +- modules/mig_with_percent/main.tf | 23 +++++++------ modules/mig_with_percent/metadata.yaml | 32 +++++++++---------- modules/mig_with_percent/variables.tf | 25 +++++++++------ .../metadata.yaml | 4 +-- modules/umig/metadata.yaml | 5 +-- 16 files changed, 130 insertions(+), 120 deletions(-) diff --git a/autogen/main.tf.tmpl b/autogen/main.tf.tmpl index a2755bcb..787fccbf 100644 --- a/autogen/main.tf.tmpl +++ b/autogen/main.tf.tmpl @@ -108,18 +108,23 @@ resource "google_compute_region_instance_group_manager" "{{ module_name }}" { dynamic "update_policy" { for_each = var.update_policy content { - instance_redistribution_type = lookup(update_policy.value, "instance_redistribution_type", null) - max_surge_fixed = lookup(update_policy.value, "max_surge_fixed", null) - max_surge_percent = lookup(update_policy.value, "max_surge_percent", null) - max_unavailable_fixed = lookup(update_policy.value, "max_unavailable_fixed", null) - max_unavailable_percent = lookup(update_policy.value, "max_unavailable_percent", null) - min_ready_sec = lookup(update_policy.value, "min_ready_sec", null) - replacement_method = lookup(update_policy.value, "replacement_method", null) - minimal_action = update_policy.value.minimal_action - type = update_policy.value.type + instance_redistribution_type = lookup(update_policy.value, "instance_redistribution_type", null) + max_surge_fixed = lookup(update_policy.value, "max_surge_fixed", null) + max_surge_percent = lookup(update_policy.value, "max_surge_percent", null) + max_unavailable_fixed = lookup(update_policy.value, "max_unavailable_fixed", null) + max_unavailable_percent = lookup(update_policy.value, "max_unavailable_percent", null) + min_ready_sec = lookup(update_policy.value, "min_ready_sec", null) + replacement_method = lookup(update_policy.value, "replacement_method", null) + most_disruptive_allowed_action = lookup(update_policy.value, "most_disruptive_allowed_action", null) + minimal_action = update_policy.value.minimal_action + type = update_policy.value.type } } + all_instances_config { + labels = var.labels + } + lifecycle { create_before_destroy = true ignore_changes = [distribution_policy_zones] diff --git a/autogen/variables.tf.tmpl b/autogen/variables.tf.tmpl index 6363798b..7589746a 100644 --- a/autogen/variables.tf.tmpl +++ b/autogen/variables.tf.tmpl @@ -118,15 +118,16 @@ variable "stateful_ips" { variable "update_policy" { description = "The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy" type = list(object({ - max_surge_fixed = number - instance_redistribution_type = string - max_surge_percent = number - max_unavailable_fixed = number - max_unavailable_percent = number - min_ready_sec = number - replacement_method = string - minimal_action = string - type = string + max_surge_fixed = number + instance_redistribution_type = string + max_surge_percent = number + max_unavailable_fixed = number + max_unavailable_percent = number + min_ready_sec = number + replacement_method = string + minimal_action = string + type = string + most_disruptive_allowed_action = string })) default = [] } @@ -296,3 +297,9 @@ variable "mig_timeouts" { delete = "15m" } } + +variable "labels" { + type = map(string) + description = "Labels, provided as a map" + default = {} +} diff --git a/metadata.yaml b/metadata.yaml index fb23294a..20a33f59 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/modules/compute_disk_snapshot/metadata.yaml b/modules/compute_disk_snapshot/metadata.yaml index c57e1b43..789c5e54 100644 --- a/modules/compute_disk_snapshot/metadata.yaml +++ b/modules/compute_disk_snapshot/metadata.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -85,17 +85,14 @@ spec: - name: name description: Name of the resource policy to create varType: string - defaultValue: null required: true - name: project description: The project ID where the resources will be created varType: string - defaultValue: null required: true - name: region description: Region where resource policy resides varType: string - defaultValue: null required: true - name: snapshot_properties description: The properties of the schedule policy. For more details see https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_resource_policy#snapshot_properties @@ -107,7 +104,6 @@ spec: storage_locations = list(string) } ) - defaultValue: null - name: snapshot_retention_policy description: The retention policy to be applied to the schedule policy. For more details see https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_resource_policy#retention_policy varType: |- @@ -117,7 +113,6 @@ spec: on_source_disk_delete = string } ) - defaultValue: null required: true - name: snapshot_schedule description: The scheduled to be used by the snapshot policy. For more details see https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_resource_policy#schedule @@ -148,7 +143,6 @@ spec: ) } ) - defaultValue: null required: true outputs: - name: attachments diff --git a/modules/compute_instance/metadata.yaml b/modules/compute_instance/metadata.yaml index 2e9e08f0..578f6c48 100644 --- a/modules/compute_instance/metadata.yaml +++ b/modules/compute_instance/metadata.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -109,7 +109,6 @@ spec: - name: instance_template description: Instance template self_link used to create compute instances varType: string - defaultValue: null required: true - name: ipv6_access_config description: IPv6 access configurations. Currently a max of 1 IPv6 access configuration is supported. If not specified, the instance will have no external IPv6 Internet access. @@ -121,7 +120,6 @@ spec: - name: labels description: (Optional) Labels to override those from the template, provided as a map varType: map(string) - defaultValue: null - name: network description: Network to deploy to. Only one of network or subnetwork should be specified. varType: string @@ -133,11 +131,9 @@ spec: - name: region description: Region where the instances should be created. varType: string - defaultValue: null - name: resource_manager_tags description: (Optional) A tag is a key-value pair that can be attached to a Google Cloud resource. You can use tags to conditionally allow or deny policies based on whether a resource has a specific tag. This value is not returned by the API. In Terraform, this value cannot be updated and changing it will recreate the resource. varType: map(string) - defaultValue: null - name: resource_policies description: (Optional) A list of short names or self_links of resource policies to attach to the instance. Modifying this list will cause the instance to recreate. Currently a max of 1 resource policy is supported. varType: list(string) @@ -157,7 +153,6 @@ spec: - name: zone description: Zone where the instances should be created. If not specified, instances will be spread across available zones in the region. varType: string - defaultValue: null outputs: - name: available_zones description: List of available zones in region diff --git a/modules/instance_template/metadata.yaml b/modules/instance_template/metadata.yaml index b90fcce5..80b2e28f 100644 --- a/modules/instance_template/metadata.yaml +++ b/modules/instance_template/metadata.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -130,7 +130,6 @@ spec: ip_cidr_range = string subnetwork_range_name = string }) - defaultValue: null - name: auto_delete description: Whether or not the boot disk should be auto-deleted varType: string @@ -146,7 +145,6 @@ spec: - name: disk_encryption_key description: The id of the encryption key that is stored in Google Cloud KMS to use to encrypt all the disks on this instance varType: string - defaultValue: null - name: disk_labels description: Labels to be assigned to boot disk, provided as a map varType: map(string) @@ -178,7 +176,6 @@ spec: type = string count = number }) - defaultValue: null - name: ipv6_access_config description: IPv6 access configurations. Currently a max of 1 IPv6 access configuration is supported. If not specified, the instance will have no external IPv6 Internet access. varType: |- @@ -201,7 +198,6 @@ spec: - name: min_cpu_platform description: "Specifies a minimum CPU platform. Applicable values are the friendly names of CPU platforms, such as Intel Haswell or Intel Skylake. See the complete list: https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform" varType: string - defaultValue: null - name: name_prefix description: Name prefix for the instance template varType: string @@ -217,7 +213,6 @@ spec: - name: nic_type description: Valid values are "VIRTIO_NET", "GVNIC" or set to null to accept API default behavior. varType: string - defaultValue: null - name: on_host_maintenance description: Instance availability Policy varType: string @@ -229,11 +224,9 @@ spec: - name: project_id description: The GCP project ID varType: string - defaultValue: null - name: region description: Region where the instance template should be created. varType: string - defaultValue: null - name: resource_policies description: A list of self_links of resource policies to attach to the instance. Modifying this list will cause the instance to recreate. Currently a max of 1 resource policy is supported. varType: list(string) @@ -245,7 +238,6 @@ spec: email = string scopes = set(string) }) - defaultValue: null required: true - name: shielded_instance_config description: Not used unless enable_shielded_vm is true. Shielded VM configuration for the instance. @@ -282,7 +274,6 @@ spec: - name: stack_type description: The stack type for this network interface to identify whether the IPv6 feature is enabled or not. Values are `IPV4_IPV6` or `IPV4_ONLY`. Default behavior is equivalent to IPV4_ONLY. varType: string - defaultValue: null - name: startup_script description: User startup script to run when instances spin up varType: string @@ -302,7 +293,6 @@ spec: - name: threads_per_core description: The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. varType: number - defaultValue: null - name: total_egress_bandwidth_tier description: Egress bandwidth tier setting for supported VM families varType: string diff --git a/modules/mig/README.md b/modules/mig/README.md index 4d5aeab9..216bcaa3 100644 --- a/modules/mig/README.md +++ b/modules/mig/README.md @@ -32,6 +32,7 @@ The current version is 2.X. The following guides are available to assist with up | health\_check\_name | Health check name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no | | hostname | Hostname prefix for instances | `string` | `"default"` | no | | instance\_template | Instance template self\_link used to create compute instances | `string` | n/a | yes | +| labels | Labels, provided as a map | `map(string)` | `{}` | no | | max\_replicas | The maximum number of instances that the autoscaler can scale up to. This is required when creating or updating an autoscaler. The maximum number of replicas should not be lower than minimal number of replicas. | `number` | `10` | no | | mig\_name | Managed instance group name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no | | mig\_timeouts | Times for creation, deleting and updating the MIG resources. Can be helpful when using wait\_for\_instances to allow a longer VM startup time. |
object({
create = string
update = string
delete = string
})
|
{
"create": "5m",
"delete": "15m",
"update": "5m"
}
| no | @@ -44,7 +45,7 @@ The current version is 2.X. The following guides are available to assist with up | stateful\_ips | Statful IPs created on the instances that will be preserved on instance delete. https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-ip-addresses-in-migs |
list(object({
interface_name = string
delete_rule = string
is_external = bool
}))
| `[]` | no | | target\_pools | The target load balancing pools to assign this group to. | `list(string)` | `[]` | no | | target\_size | The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. | `number` | `1` | no | -| update\_policy | The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy |
list(object({
max_surge_fixed = number
instance_redistribution_type = string
max_surge_percent = number
max_unavailable_fixed = number
max_unavailable_percent = number
min_ready_sec = number
replacement_method = string
minimal_action = string
type = string
}))
| `[]` | no | +| update\_policy | The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy |
list(object({
max_surge_fixed = number
instance_redistribution_type = string
max_surge_percent = number
max_unavailable_fixed = number
max_unavailable_percent = number
min_ready_sec = number
replacement_method = string
minimal_action = string
type = string
most_disruptive_allowed_action = string
}))
| `[]` | no | | wait\_for\_instances | Whether to wait for all instances to be created/updated before returning. Note that if this is set to true and the operation does not succeed, Terraform will continue trying until it times out. | `string` | `"false"` | no | ## Outputs diff --git a/modules/mig/main.tf b/modules/mig/main.tf index f2515068..2b3e2696 100644 --- a/modules/mig/main.tf +++ b/modules/mig/main.tf @@ -92,18 +92,23 @@ resource "google_compute_region_instance_group_manager" "mig" { dynamic "update_policy" { for_each = var.update_policy content { - instance_redistribution_type = lookup(update_policy.value, "instance_redistribution_type", null) - max_surge_fixed = lookup(update_policy.value, "max_surge_fixed", null) - max_surge_percent = lookup(update_policy.value, "max_surge_percent", null) - max_unavailable_fixed = lookup(update_policy.value, "max_unavailable_fixed", null) - max_unavailable_percent = lookup(update_policy.value, "max_unavailable_percent", null) - min_ready_sec = lookup(update_policy.value, "min_ready_sec", null) - replacement_method = lookup(update_policy.value, "replacement_method", null) - minimal_action = update_policy.value.minimal_action - type = update_policy.value.type + instance_redistribution_type = lookup(update_policy.value, "instance_redistribution_type", null) + max_surge_fixed = lookup(update_policy.value, "max_surge_fixed", null) + max_surge_percent = lookup(update_policy.value, "max_surge_percent", null) + max_unavailable_fixed = lookup(update_policy.value, "max_unavailable_fixed", null) + max_unavailable_percent = lookup(update_policy.value, "max_unavailable_percent", null) + min_ready_sec = lookup(update_policy.value, "min_ready_sec", null) + replacement_method = lookup(update_policy.value, "replacement_method", null) + most_disruptive_allowed_action = lookup(update_policy.value, "most_disruptive_allowed_action", null) + minimal_action = update_policy.value.minimal_action + type = update_policy.value.type } } + all_instances_config { + labels = var.labels + } + lifecycle { create_before_destroy = true ignore_changes = [distribution_policy_zones] diff --git a/modules/mig/metadata.yaml b/modules/mig/metadata.yaml index ec6a1dbd..536c4580 100644 --- a/modules/mig/metadata.yaml +++ b/modules/mig/metadata.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -106,7 +106,6 @@ spec: - name: autoscaling_mode description: Operating mode of the autoscaling policy. If omitted, the default value is ON. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_autoscaler#mode varType: string - defaultValue: null - name: autoscaling_scale_in_control description: Autoscaling, scale-in control block. https://www.terraform.io/docs/providers/google/r/compute_autoscaler#scale_in_control varType: |- @@ -126,7 +125,6 @@ spec: - name: distribution_policy_target_shape description: MIG target distribution shape (EVEN, BALANCED, ANY, ANY_SINGLE_ZONE) varType: string - defaultValue: null - name: distribution_policy_zones description: The distribution policy, i.e. which zone(s) should instances be create in. Default is all zones in given region. varType: list(string) @@ -174,8 +172,11 @@ spec: - name: instance_template description: Instance template self_link used to create compute instances varType: string - defaultValue: null required: true + - name: labels + description: Labels, provided as a map + varType: map(string) + defaultValue: {} - name: max_replicas description: The maximum number of instances that the autoscaler can scale up to. This is required when creating or updating an autoscaler. The maximum number of replicas should not be lower than minimal number of replicas. varType: number @@ -211,11 +212,9 @@ spec: - name: project_id description: The GCP project ID varType: string - defaultValue: null - name: region description: The GCP region where the managed instance group resides. varType: string - defaultValue: null required: true - name: scaling_schedules description: Autoscaling, scaling schedule block. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_autoscaler#scaling_schedules @@ -258,15 +257,16 @@ spec: description: The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy varType: |- list(object({ - max_surge_fixed = number - instance_redistribution_type = string - max_surge_percent = number - max_unavailable_fixed = number - max_unavailable_percent = number - min_ready_sec = number - replacement_method = string - minimal_action = string - type = string + max_surge_fixed = number + instance_redistribution_type = string + max_surge_percent = number + max_unavailable_fixed = number + max_unavailable_percent = number + min_ready_sec = number + replacement_method = string + minimal_action = string + type = string + most_disruptive_allowed_action = string })) defaultValue: [] - name: wait_for_instances diff --git a/modules/mig/variables.tf b/modules/mig/variables.tf index 767bb51f..e440ee2e 100644 --- a/modules/mig/variables.tf +++ b/modules/mig/variables.tf @@ -100,15 +100,16 @@ variable "stateful_ips" { variable "update_policy" { description = "The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy" type = list(object({ - max_surge_fixed = number - instance_redistribution_type = string - max_surge_percent = number - max_unavailable_fixed = number - max_unavailable_percent = number - min_ready_sec = number - replacement_method = string - minimal_action = string - type = string + max_surge_fixed = number + instance_redistribution_type = string + max_surge_percent = number + max_unavailable_fixed = number + max_unavailable_percent = number + min_ready_sec = number + replacement_method = string + minimal_action = string + type = string + most_disruptive_allowed_action = string })) default = [] } @@ -278,3 +279,9 @@ variable "mig_timeouts" { delete = "15m" } } + +variable "labels" { + type = map(string) + description = "Labels, provided as a map" + default = {} +} diff --git a/modules/mig_with_percent/README.md b/modules/mig_with_percent/README.md index 08ba215f..5e10aec7 100644 --- a/modules/mig_with_percent/README.md +++ b/modules/mig_with_percent/README.md @@ -32,6 +32,7 @@ The current version is 2.X. The following guides are available to assist with up | hostname | Hostname prefix for instances | `string` | `"default"` | no | | instance\_template\_initial\_version | Instance template self\_link used to create compute instances for the initial version | `string` | n/a | yes | | instance\_template\_next\_version | Instance template self\_link used to create compute instances for the second version | `string` | n/a | yes | +| labels | Labels, provided as a map | `map(string)` | `{}` | no | | max\_replicas | The maximum number of instances that the autoscaler can scale up to. This is required when creating or updating an autoscaler. The maximum number of replicas should not be lower than minimal number of replicas. | `number` | `10` | no | | mig\_name | Managed instance group name. When variable is empty, name will be derived from var.hostname. | `string` | `""` | no | | mig\_timeouts | Times for creation, deleting and updating the MIG resources. Can be helpful when using wait\_for\_instances to allow a longer VM startup time. |
object({
create = string
update = string
delete = string
})
|
{
"create": "5m",
"delete": "15m",
"update": "5m"
}
| no | @@ -45,7 +46,7 @@ The current version is 2.X. The following guides are available to assist with up | stateful\_ips | Statful IPs created on the instances that will be preserved on instance delete. https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-ip-addresses-in-migs |
list(object({
interface_name = string
delete_rule = string
is_external = bool
}))
| `[]` | no | | target\_pools | The target load balancing pools to assign this group to. | `list(string)` | `[]` | no | | target\_size | The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. | `number` | `1` | no | -| update\_policy | The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy |
list(object({
max_surge_fixed = number
instance_redistribution_type = string
max_surge_percent = number
max_unavailable_fixed = number
max_unavailable_percent = number
min_ready_sec = number
replacement_method = string
minimal_action = string
type = string
}))
| `[]` | no | +| update\_policy | The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy |
list(object({
max_surge_fixed = number
instance_redistribution_type = string
max_surge_percent = number
max_unavailable_fixed = number
max_unavailable_percent = number
min_ready_sec = number
replacement_method = string
minimal_action = string
type = string
most_disruptive_allowed_action = string
}))
| `[]` | no | | wait\_for\_instances | Whether to wait for all instances to be created/updated before returning. Note that if this is set to true and the operation does not succeed, Terraform will continue trying until it times out. | `string` | `"false"` | no | ## Outputs diff --git a/modules/mig_with_percent/main.tf b/modules/mig_with_percent/main.tf index bd0a4490..e70649c5 100644 --- a/modules/mig_with_percent/main.tf +++ b/modules/mig_with_percent/main.tf @@ -101,18 +101,23 @@ resource "google_compute_region_instance_group_manager" "mig_with_percent" { dynamic "update_policy" { for_each = var.update_policy content { - instance_redistribution_type = lookup(update_policy.value, "instance_redistribution_type", null) - max_surge_fixed = lookup(update_policy.value, "max_surge_fixed", null) - max_surge_percent = lookup(update_policy.value, "max_surge_percent", null) - max_unavailable_fixed = lookup(update_policy.value, "max_unavailable_fixed", null) - max_unavailable_percent = lookup(update_policy.value, "max_unavailable_percent", null) - min_ready_sec = lookup(update_policy.value, "min_ready_sec", null) - replacement_method = lookup(update_policy.value, "replacement_method", null) - minimal_action = update_policy.value.minimal_action - type = update_policy.value.type + instance_redistribution_type = lookup(update_policy.value, "instance_redistribution_type", null) + max_surge_fixed = lookup(update_policy.value, "max_surge_fixed", null) + max_surge_percent = lookup(update_policy.value, "max_surge_percent", null) + max_unavailable_fixed = lookup(update_policy.value, "max_unavailable_fixed", null) + max_unavailable_percent = lookup(update_policy.value, "max_unavailable_percent", null) + min_ready_sec = lookup(update_policy.value, "min_ready_sec", null) + replacement_method = lookup(update_policy.value, "replacement_method", null) + most_disruptive_allowed_action = lookup(update_policy.value, "most_disruptive_allowed_action", null) + minimal_action = update_policy.value.minimal_action + type = update_policy.value.type } } + all_instances_config { + labels = var.labels + } + lifecycle { create_before_destroy = true ignore_changes = [distribution_policy_zones] diff --git a/modules/mig_with_percent/metadata.yaml b/modules/mig_with_percent/metadata.yaml index aaa0f551..dcfe1c9c 100644 --- a/modules/mig_with_percent/metadata.yaml +++ b/modules/mig_with_percent/metadata.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -106,7 +106,6 @@ spec: - name: autoscaling_mode description: Operating mode of the autoscaling policy. If omitted, the default value is ON. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_autoscaler#mode varType: string - defaultValue: null - name: autoscaling_scale_in_control description: Autoscaling, scale-in control block. https://www.terraform.io/docs/providers/google/r/compute_autoscaler#scale_in_control varType: |- @@ -126,7 +125,6 @@ spec: - name: distribution_policy_target_shape description: MIG target distribution shape (EVEN, BALANCED, ANY, ANY_SINGLE_ZONE) varType: string - defaultValue: null - name: distribution_policy_zones description: The distribution policy, i.e. which zone(s) should instances be create in. Default is all zones in given region. varType: list(string) @@ -174,13 +172,15 @@ spec: - name: instance_template_initial_version description: Instance template self_link used to create compute instances for the initial version varType: string - defaultValue: null required: true - name: instance_template_next_version description: Instance template self_link used to create compute instances for the second version varType: string - defaultValue: null required: true + - name: labels + description: Labels, provided as a map + varType: map(string) + defaultValue: {} - name: max_replicas description: The maximum number of instances that the autoscaler can scale up to. This is required when creating or updating an autoscaler. The maximum number of replicas should not be lower than minimal number of replicas. varType: number @@ -216,16 +216,13 @@ spec: - name: next_version_percent description: Percentage of instances defined in the second version varType: number - defaultValue: null required: true - name: project_id description: The GCP project ID varType: string - defaultValue: null - name: region description: The GCP region where the managed instance group resides. varType: string - defaultValue: null required: true - name: scaling_schedules description: Autoscaling, scaling schedule block. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_autoscaler#scaling_schedules @@ -268,15 +265,16 @@ spec: description: The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy varType: |- list(object({ - max_surge_fixed = number - instance_redistribution_type = string - max_surge_percent = number - max_unavailable_fixed = number - max_unavailable_percent = number - min_ready_sec = number - replacement_method = string - minimal_action = string - type = string + max_surge_fixed = number + instance_redistribution_type = string + max_surge_percent = number + max_unavailable_fixed = number + max_unavailable_percent = number + min_ready_sec = number + replacement_method = string + minimal_action = string + type = string + most_disruptive_allowed_action = string })) defaultValue: [] - name: wait_for_instances diff --git a/modules/mig_with_percent/variables.tf b/modules/mig_with_percent/variables.tf index e6f6268d..759cd9de 100644 --- a/modules/mig_with_percent/variables.tf +++ b/modules/mig_with_percent/variables.tf @@ -110,15 +110,16 @@ variable "stateful_ips" { variable "update_policy" { description = "The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy" type = list(object({ - max_surge_fixed = number - instance_redistribution_type = string - max_surge_percent = number - max_unavailable_fixed = number - max_unavailable_percent = number - min_ready_sec = number - replacement_method = string - minimal_action = string - type = string + max_surge_fixed = number + instance_redistribution_type = string + max_surge_percent = number + max_unavailable_fixed = number + max_unavailable_percent = number + min_ready_sec = number + replacement_method = string + minimal_action = string + type = string + most_disruptive_allowed_action = string })) default = [] } @@ -288,3 +289,9 @@ variable "mig_timeouts" { delete = "15m" } } + +variable "labels" { + type = map(string) + description = "Labels, provided as a map" + default = {} +} diff --git a/modules/preemptible_and_regular_instance_templates/metadata.yaml b/modules/preemptible_and_regular_instance_templates/metadata.yaml index a05f0a44..75b0a1fe 100644 --- a/modules/preemptible_and_regular_instance_templates/metadata.yaml +++ b/modules/preemptible_and_regular_instance_templates/metadata.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -141,7 +141,6 @@ spec: - name: project_id description: The GCP project ID varType: string - defaultValue: null - name: service_account description: Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. varType: |- @@ -149,7 +148,6 @@ spec: email = string scopes = set(string) }) - defaultValue: null required: true - name: source_image description: Source disk image. If neither source_image nor source_image_family is specified, defaults to the latest public Rocky Linux 9 optimized for GCP image. diff --git a/modules/umig/metadata.yaml b/modules/umig/metadata.yaml index bd8d36ba..07cfb6a3 100644 --- a/modules/umig/metadata.yaml +++ b/modules/umig/metadata.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -110,7 +110,6 @@ spec: - name: instance_template description: Instance template self_link used to create compute instances varType: string - defaultValue: null required: true - name: ipv6_access_config description: IPv6 access configurations. Currently a max of 1 IPv6 access configuration is supported. If not specified, the instance will have no external IPv6 Internet access. @@ -138,11 +137,9 @@ spec: - name: project_id description: The GCP project ID varType: string - defaultValue: null - name: region description: The GCP region where the unmanaged instance group resides. varType: string - defaultValue: null required: true - name: static_ips description: List of static IPs for VM instances From 5e640ec8c1e8f43816857b3a66dcd336b9b86119 Mon Sep 17 00:00:00 2001 From: Rauny Date: Tue, 20 Feb 2024 17:21:17 +0100 Subject: [PATCH 2/3] fix: linting --- examples/mig_stateful/main.tf | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/mig_stateful/main.tf b/examples/mig_stateful/main.tf index 7c9ac788..3910dfd8 100644 --- a/examples/mig_stateful/main.tf +++ b/examples/mig_stateful/main.tf @@ -69,14 +69,15 @@ module "mig" { }] update_policy = [{ - max_surge_fixed = 0 - instance_redistribution_type = "NONE" - max_surge_percent = null - max_unavailable_fixed = 4 - max_unavailable_percent = null - min_ready_sec = 180 - replacement_method = "RECREATE" - minimal_action = "REFRESH" - type = "OPPORTUNISTIC" + max_surge_fixed = 0 + instance_redistribution_type = "NONE" + max_surge_percent = null + max_unavailable_fixed = 4 + max_unavailable_percent = null + min_ready_sec = 180 + replacement_method = "RECREATE" + minimal_action = "REFRESH" + type = "OPPORTUNISTIC" + most_disruptive_allowed_action = "REFRESH" }] } From 17de49db3c6f02f6d8d776a44ee9d7438c1b4026 Mon Sep 17 00:00:00 2001 From: Rauny Date: Tue, 20 Feb 2024 18:16:55 +0100 Subject: [PATCH 3/3] fix: linting --- examples/mig/full/variables.tf | 19 ++++++++++--------- modules/instance_template/metadata.yaml | 1 - 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/mig/full/variables.tf b/examples/mig/full/variables.tf index e89f681c..fb875961 100644 --- a/examples/mig/full/variables.tf +++ b/examples/mig/full/variables.tf @@ -169,15 +169,16 @@ variable "distribution_policy_zones" { variable "update_policy" { description = "The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy" type = list(object({ - max_surge_fixed = number - instance_redistribution_type = string - max_surge_percent = number - max_unavailable_fixed = number - max_unavailable_percent = number - min_ready_sec = number - replacement_method = string - minimal_action = string - type = string + max_surge_fixed = number + instance_redistribution_type = string + max_surge_percent = number + max_unavailable_fixed = number + max_unavailable_percent = number + min_ready_sec = number + replacement_method = string + minimal_action = string + type = string + most_disruptive_allowed_action = string })) default = [] } diff --git a/modules/instance_template/metadata.yaml b/modules/instance_template/metadata.yaml index 85732f83..a0f27de8 100644 --- a/modules/instance_template/metadata.yaml +++ b/modules/instance_template/metadata.yaml @@ -194,7 +194,6 @@ spec: - name: maintenance_interval description: Specifies the frequency of planned maintenance events varType: string - defaultValue: null - name: metadata description: Metadata, provided as a map varType: map(string)