Skip to content

Commit

Permalink
Merge branch 'master' into feat/supporting_template_description
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody authored Jul 3, 2024
2 parents 836ef79 + 9a46b2e commit 50cbbb3
Show file tree
Hide file tree
Showing 23 changed files with 182 additions and 156 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Make will use bash instead of sh
SHELL := /usr/bin/env bash

DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.19
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.21
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd
ENABLE_BPMETADATA := 1
Expand Down
16 changes: 8 additions & 8 deletions autogen/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +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
max_surge_fixed = optional(number)
instance_redistribution_type = optional(string)
max_surge_percent = optional(number)
max_unavailable_fixed = optional(number)
max_unavailable_percent = optional(number)
min_ready_sec = optional(number)
replacement_method = optional(string)
minimal_action = string
type = string
most_disruptive_allowed_action = string
most_disruptive_allowed_action = optional(string)
}))
default = []
}
Expand Down
2 changes: 1 addition & 1 deletion autogen/versions.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

terraform {
required_version = ">=0.13.0"
required_version = ">=1.3.0"
required_providers {
google = {
source = "hashicorp/google"
Expand Down
2 changes: 1 addition & 1 deletion build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,4 @@ tags:
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.19'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.21'
2 changes: 1 addition & 1 deletion build/lint.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ tags:
- 'lint'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.19'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.21'
16 changes: 8 additions & 8 deletions examples/mig/full/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +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
max_surge_fixed = optional(number)
instance_redistribution_type = optional(string)
max_surge_percent = optional(number)
max_unavailable_fixed = optional(number)
max_unavailable_percent = optional(number)
min_ready_sec = optional(number)
replacement_method = optional(string)
minimal_action = string
type = string
most_disruptive_allowed_action = string
most_disruptive_allowed_action = optional(string)
}))
default = []
}
Expand Down
3 changes: 2 additions & 1 deletion modules/instance_template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| access\_config | Access configurations, i.e. IPs via which the VM instance can be accessed via the Internet. | <pre>list(object({<br> nat_ip = string<br> network_tier = string<br> }))</pre> | `[]` | no |
| additional\_disks | List of maps of additional disks. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#disk_name | <pre>list(object({<br> disk_name = string<br> device_name = string<br> auto_delete = bool<br> boot = bool<br> disk_size_gb = number<br> disk_type = string<br> disk_labels = map(string)<br> source_snapshot = optional(string)<br> }))</pre> | `[]` | no |
| additional\_disks | List of maps of additional disks. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#disk_name | <pre>list(object({<br> auto_delete = optional(bool, true)<br> boot = optional(bool, false)<br> device_name = optional(string)<br> disk_name = optional(string)<br> disk_size_gb = optional(number)<br> disk_type = optional(string)<br> disk_labels = optional(map(string), {})<br> interface = optional(string)<br> mode = optional(string)<br> source = optional(string)<br> source_image = optional(string)<br> source_snapshot = optional(string)<br> }))</pre> | `[]` | no |
| additional\_networks | Additional network interface details for GCE, if any. | <pre>list(object({<br> network = string<br> subnetwork = string<br> subnetwork_project = string<br> network_ip = string<br> nic_type = string<br> stack_type = string<br> queue_count = number<br> access_config = list(object({<br> nat_ip = string<br> network_tier = string<br> }))<br> ipv6_access_config = list(object({<br> network_tier = string<br> }))<br> alias_ip_range = list(object({<br> ip_cidr_range = string<br> subnetwork_range_name = string<br> }))<br> }))</pre> | `[]` | no |
| alias\_ip\_range | An array of alias IP ranges for this network interface. Can only be specified for network interfaces on subnet-mode networks.<br>ip\_cidr\_range: The IP CIDR range represented by this alias IP range. This IP CIDR range must belong to the specified subnetwork and cannot contain IP addresses reserved by system or used by other network interfaces. At the time of writing only a netmask (e.g. /24) may be supplied, with a CIDR format resulting in an API error.<br>subnetwork\_range\_name: The subnetwork secondary range name specifying the secondary range from which to allocate the IP CIDR range for this alias IP range. If left unspecified, the primary range of the subnetwork will be used. | <pre>object({<br> ip_cidr_range = string<br> subnetwork_range_name = string<br> })</pre> | `null` | no |
| auto\_delete | Whether or not the boot disk should be auto-deleted | `string` | `"true"` | no |
Expand All @@ -23,6 +23,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example.
| description | The template's description | `""` |`string` | no |
| disk\_encryption\_key | The id of the encryption key that is stored in Google Cloud KMS to use to encrypt all the disks on this instance | `string` | `null` | no |
| disk\_labels | Labels to be assigned to boot disk, provided as a map | `map(string)` | `{}` | no |
| disk\_resource\_policies | A list (short name or id) of resource policies to attach to this disk for automatic snapshot creations | `list(string)` | `[]` | no |
| disk\_size\_gb | Boot disk size in GB | `string` | `"100"` | no |
| disk\_type | Boot disk type, can be either pd-ssd, local-ssd, or pd-standard | `string` | `"pd-standard"` | no |
| enable\_confidential\_vm | Whether to enable the Confidential VM configuration on the instance. Note that the instance image must support Confidential VMs. See https://cloud.google.com/compute/docs/images | `bool` | `false` | no |
Expand Down
40 changes: 21 additions & 19 deletions modules/instance_template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ locals {

boot_disk = [
{
source_image = var.source_image != "" ? format("${local.source_image_project}/${local.source_image}") : format("${local.source_image_project}/${local.source_image_family}")
disk_size_gb = var.disk_size_gb
disk_type = var.disk_type
disk_labels = var.disk_labels
auto_delete = var.auto_delete
boot = "true"
source_image = var.source_image != "" ? format("${local.source_image_project}/${local.source_image}") : format("${local.source_image_project}/${local.source_image_family}")
disk_size_gb = var.disk_size_gb
disk_type = var.disk_type
disk_labels = var.disk_labels
auto_delete = var.auto_delete
boot = "true"
resource_policies = var.disk_resource_policies
},
]

Expand Down Expand Up @@ -80,19 +81,20 @@ resource "google_compute_instance_template" "tpl" {
dynamic "disk" {
for_each = local.all_disks
content {
auto_delete = lookup(disk.value, "auto_delete", null)
boot = lookup(disk.value, "boot", null)
device_name = lookup(disk.value, "device_name", null)
disk_name = lookup(disk.value, "disk_name", null)
disk_size_gb = lookup(disk.value, "disk_size_gb", lookup(disk.value, "disk_type", null) == "local-ssd" ? "375" : null)
disk_type = lookup(disk.value, "disk_type", null)
interface = lookup(disk.value, "interface", lookup(disk.value, "disk_type", null) == "local-ssd" ? "NVME" : null)
mode = lookup(disk.value, "mode", null)
source = lookup(disk.value, "source", null)
source_image = lookup(disk.value, "source_image", null)
source_snapshot = lookup(disk.value, "source_snapshot", null)
type = lookup(disk.value, "disk_type", null) == "local-ssd" ? "SCRATCH" : "PERSISTENT"
labels = lookup(disk.value, "disk_labels", null)
auto_delete = lookup(disk.value, "auto_delete", null)
boot = lookup(disk.value, "boot", null)
device_name = lookup(disk.value, "device_name", null)
disk_name = lookup(disk.value, "disk_name", null)
disk_size_gb = lookup(disk.value, "disk_size_gb", lookup(disk.value, "disk_type", null) == "local-ssd" ? "375" : null)
disk_type = lookup(disk.value, "disk_type", null)
interface = lookup(disk.value, "interface", lookup(disk.value, "disk_type", null) == "local-ssd" ? "NVME" : null)
mode = lookup(disk.value, "mode", null)
source = lookup(disk.value, "source", null)
source_image = lookup(disk.value, "source_image", null)
source_snapshot = lookup(disk.value, "source_snapshot", null)
type = lookup(disk.value, "disk_type", null) == "local-ssd" ? "SCRATCH" : "PERSISTENT"
labels = lookup(disk.value, "disk_labels", null)
resource_policies = lookup(disk.value, "resource_policies", [])

dynamic "disk_encryption_key" {
for_each = compact([var.disk_encryption_key == null ? null : 1])
Expand Down
24 changes: 16 additions & 8 deletions modules/instance_template/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
version: 11.1.0
actuationTool:
flavor: Terraform
version: ">=0.13.0"
version: ">=1.3"
description: {}
content:
examples:
Expand Down Expand Up @@ -86,13 +86,17 @@ spec:
description: List of maps of additional disks. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#disk_name
varType: |-
list(object({
disk_name = string
device_name = string
auto_delete = bool
boot = bool
disk_size_gb = number
disk_type = string
disk_labels = map(string)
auto_delete = optional(bool, true)
boot = optional(bool, false)
device_name = optional(string)
disk_name = optional(string)
disk_size_gb = optional(number)
disk_type = optional(string)
disk_labels = optional(map(string), {})
interface = optional(string)
mode = optional(string)
source = optional(string)
source_image = optional(string)
source_snapshot = optional(string)
}))
defaultValue: []
Expand Down Expand Up @@ -149,6 +153,10 @@ spec:
description: Labels to be assigned to boot disk, provided as a map
varType: map(string)
defaultValue: {}
- name: disk_resource_policies
description: A list (short name or id) of resource policies to attach to this disk for automatic snapshot creations
varType: list(string)
defaultValue: []
- name: disk_size_gb
description: Boot disk size in GB
varType: string
Expand Down
24 changes: 17 additions & 7 deletions modules/instance_template/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,28 @@ variable "auto_delete" {
variable "additional_disks" {
description = "List of maps of additional disks. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#disk_name"
type = list(object({
disk_name = string
device_name = string
auto_delete = bool
boot = bool
disk_size_gb = number
disk_type = string
disk_labels = map(string)
auto_delete = optional(bool, true)
boot = optional(bool, false)
device_name = optional(string)
disk_name = optional(string)
disk_size_gb = optional(number)
disk_type = optional(string)
disk_labels = optional(map(string), {})
interface = optional(string)
mode = optional(string)
source = optional(string)
source_image = optional(string)
source_snapshot = optional(string)
}))
default = []
}

variable "disk_resource_policies" {
description = "A list (short name or id) of resource policies to attach to this disk for automatic snapshot creations"
type = list(string)
default = []
}

####################
# network_interface
####################
Expand Down
2 changes: 1 addition & 1 deletion modules/instance_template/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

terraform {
required_version = ">=0.13.0"
required_version = ">=1.3"
required_providers {
google-beta = {
source = "hashicorp/google-beta"
Expand Down
2 changes: 1 addition & 1 deletion modules/mig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,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 | <pre>list(object({<br> interface_name = string<br> delete_rule = string<br> is_external = bool<br> }))</pre> | `[]` | 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 | <pre>list(object({<br> max_surge_fixed = number<br> instance_redistribution_type = string<br> max_surge_percent = number<br> max_unavailable_fixed = number<br> max_unavailable_percent = number<br> min_ready_sec = number<br> replacement_method = string<br> minimal_action = string<br> type = string<br> most_disruptive_allowed_action = string<br> }))</pre> | `[]` | no |
| update\_policy | The rolling update policy. https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager#rolling_update_policy | <pre>list(object({<br> max_surge_fixed = optional(number)<br> instance_redistribution_type = optional(string)<br> max_surge_percent = optional(number)<br> max_unavailable_fixed = optional(number)<br> max_unavailable_percent = optional(number)<br> min_ready_sec = optional(number)<br> replacement_method = optional(string)<br> minimal_action = string<br> type = string<br> most_disruptive_allowed_action = optional(string)<br> }))</pre> | `[]` | 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
Expand Down
18 changes: 9 additions & 9 deletions modules/mig/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
version: 11.1.0
actuationTool:
flavor: Terraform
version: ">=0.13.0"
version: ">=1.3.0"
description: {}
content:
examples:
Expand Down Expand Up @@ -257,16 +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
max_surge_fixed = optional(number)
instance_redistribution_type = optional(string)
max_surge_percent = optional(number)
max_unavailable_fixed = optional(number)
max_unavailable_percent = optional(number)
min_ready_sec = optional(number)
replacement_method = optional(string)
minimal_action = string
type = string
most_disruptive_allowed_action = string
most_disruptive_allowed_action = optional(string)
}))
defaultValue: []
- name: wait_for_instances
Expand Down
16 changes: 8 additions & 8 deletions modules/mig/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +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
max_surge_fixed = optional(number)
instance_redistribution_type = optional(string)
max_surge_percent = optional(number)
max_unavailable_fixed = optional(number)
max_unavailable_percent = optional(number)
min_ready_sec = optional(number)
replacement_method = optional(string)
minimal_action = string
type = string
most_disruptive_allowed_action = string
most_disruptive_allowed_action = optional(string)
}))
default = []
}
Expand Down
2 changes: 1 addition & 1 deletion modules/mig/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

terraform {
required_version = ">=0.13.0"
required_version = ">=1.3.0"
required_providers {
google = {
source = "hashicorp/google"
Expand Down
Loading

0 comments on commit 50cbbb3

Please sign in to comment.