diff --git a/.github/renovate.json b/.github/renovate.json index 5d9e0435..b68ca8fb 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,37 +1,34 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ - "config:base", + "config:recommended", ":semanticCommits", ":preserveSemverRanges", ":rebaseStalePrs" ], - "stabilityDays":7, + "minimumReleaseAge": "7 days", "ignorePaths": [], "labels": ["dependencies"], - "vulnerabilityAlerts":{ - "labels":[ - "type:security" - ], - "stabilityDays":0 - }, - "separateMajorMinor":false, - "constraints": { - "go": "1.20" + "vulnerabilityAlerts": { + "labels": ["type:security"], + "minimumReleaseAge": null }, + "constraints": {"go": "1.20"}, "packageRules": [ { - "matchPaths": ["examples/**", "test/**", ".github/**"], + "matchFileNames": ["examples/**", "test/**", ".github/**"], "extends": [":semanticCommitTypeAll(chore)"] }, { - "matchPaths": ["*", "modules/**"], + "matchFileNames": ["*", "modules/**"], "extends": [":semanticCommitTypeAll(fix)"] }, { - "matchDepTypes": ["module"], - "groupName": "TF modules" + "matchFileNames": ["*", "modules/**"], + "matchUpdateTypes": "major", + "commitMessagePrefix": "fix(deps)!:" }, + {"matchDepTypes": ["module"], "groupName": "TF modules"}, { "matchDepTypes": ["require"], "groupName": "GO modules", @@ -45,20 +42,24 @@ }, { "matchPackageNames": ["google", "google-beta"], - "groupName": "terraform googles" + "groupName": "Terraform Google Provider" } ], "regexManagers": [ { "fileMatch": ["(^|/)Makefile$"], - "matchStrings": ["DOCKER_TAG_VERSION_DEVELOPER_TOOLS := (?.*?)\\n"], + "matchStrings": [ + "DOCKER_TAG_VERSION_DEVELOPER_TOOLS := (?.*?)\\n" + ], "datasourceTemplate": "docker", "registryUrlTemplate": "https://gcr.io/cloud-foundation-cicd", "depNameTemplate": "cft/developer-tools" }, { "fileMatch": ["(^|/)build/(int|lint)\\.cloudbuild\\.yaml$"], - "matchStrings": [" _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '(?.*?)'\\n"], + "matchStrings": [ + " _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '(?.*?)'\\n" + ], "datasourceTemplate": "docker", "registryUrlTemplate": "https://gcr.io/cloud-foundation-cicd", "depNameTemplate": "cft/developer-tools" diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 3db17c00..1f92bf9a 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -22,6 +22,7 @@ on: jobs: stale: + if: github.repository_owner == 'GoogleCloudPlatform' || github.repository_owner == 'terraform-google-modules' runs-on: ubuntu-latest steps: - uses: actions/stale@v8 diff --git a/.kitchen.yml b/.kitchen.yml index deab526b..9b70d52b 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -102,4 +102,4 @@ suites: driver: name: terraform command_timeout: 1800 - root_module_directory: test/fixtures/mig_with_percent/simple \ No newline at end of file + root_module_directory: test/fixtures/mig_with_percent/simple diff --git a/CHANGELOG.md b/CHANGELOG.md index d080c0d8..d86c0b24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,21 @@ All notable changes to this project will be documented in this file. See [conventional-commits](https://www.conventionalcommits.org/) for commit guidelines. +## [9.0.0](https://github.com/terraform-google-modules/terraform-google-vm/compare/v8.0.1...v9.0.0) (2023-08-22) + + +### ⚠ BREAKING CHANGES + +* allow to override compute instance labels ([#311](https://github.com/terraform-google-modules/terraform-google-vm/issues/311)) +* autoscaler supporting stateful ips ([#297](https://github.com/terraform-google-modules/terraform-google-vm/issues/297)) + +### Features + +* add spot instances ([#294](https://github.com/terraform-google-modules/terraform-google-vm/issues/294)) ([99efc45](https://github.com/terraform-google-modules/terraform-google-vm/commit/99efc456097df4f28b8a78ab72ba325d0617d20c)) +* allow to override compute instance labels ([#311](https://github.com/terraform-google-modules/terraform-google-vm/issues/311)) ([aea74d1](https://github.com/terraform-google-modules/terraform-google-vm/commit/aea74d101b7219769bbb0d1559d190f3b7f08182)) +* autoscaler supporting stateful ips ([#297](https://github.com/terraform-google-modules/terraform-google-vm/issues/297)) ([5d13e8b](https://github.com/terraform-google-modules/terraform-google-vm/commit/5d13e8b876fb73691dedfe80e32ee8280f2a98b4)) +* expose distribution_policy_target_shape setting for MIGs ([#327](https://github.com/terraform-google-modules/terraform-google-vm/issues/327)) ([1c8f775](https://github.com/terraform-google-modules/terraform-google-vm/commit/1c8f7759262c0a24f83268fcb7561bb7e01e7d8b)) + ## [8.0.1](https://github.com/terraform-google-modules/terraform-google-vm/compare/v8.0.0...v8.0.1) (2023-04-06) diff --git a/autogen/versions.tf.tmpl b/autogen/versions.tf.tmpl index 8754c0dd..3c17b523 100644 --- a/autogen/versions.tf.tmpl +++ b/autogen/versions.tf.tmpl @@ -21,9 +21,9 @@ terraform { google-beta = ">= 4.48, < 5.0" } provider_meta "google" { - module_name = "blueprints/terraform/terraform-google-vm:{% if mig %}mig{% else %}mig_with_percent{% endif %}/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:{% if mig %}mig{% else %}mig_with_percent{% endif %}/v9.0.0" } provider_meta "google-beta" { - module_name = "blueprints/terraform/terraform-google-vm:{% if mig %}mig{% else %}mig_with_percent{% endif %}/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:{% if mig %}mig{% else %}mig_with_percent{% endif %}/v9.0.0" } } diff --git a/examples/mig_stateful/main.tf b/examples/mig_stateful/main.tf index fd3d2b9f..a7ece119 100644 --- a/examples/mig_stateful/main.tf +++ b/examples/mig_stateful/main.tf @@ -75,4 +75,4 @@ module "mig" { minimal_action = "REFRESH" type = "OPPORTUNISTIC" }] -} \ No newline at end of file +} diff --git a/modules/compute_disk_snapshot/versions.tf b/modules/compute_disk_snapshot/versions.tf index f4f5cc51..cc3302aa 100644 --- a/modules/compute_disk_snapshot/versions.tf +++ b/modules/compute_disk_snapshot/versions.tf @@ -21,6 +21,6 @@ terraform { null = ">= 2.1" } provider_meta "google" { - module_name = "blueprints/terraform/terraform-google-vm:compute_instance/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:compute_instance/v9.0.0" } } diff --git a/modules/compute_instance/README.md b/modules/compute_instance/README.md index 15da6fed..b0d28d8b 100644 --- a/modules/compute_instance/README.md +++ b/modules/compute_instance/README.md @@ -23,6 +23,7 @@ See the [simple](https://github.com/terraform-google-modules/terraform-google-vm | hostname\_suffix\_separator | Separator character to compose hostname when add\_hostname\_suffix is set to true. | `string` | `"-"` | no | | instance\_template | Instance template self\_link used to create compute instances | `string` | n/a | yes | | ipv6\_access\_config | 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. |
list(object({
network_tier = string
}))
| `[]` | no | +| labels | (Optional) Labels to override those from the template, provided as a map | `map(string)` | `null` | no | | network | Network to deploy to. Only one of network or subnetwork should be specified. | `string` | `""` | no | | num\_instances | Number of instances to create. This value is ignored if static\_ips is provided. | `number` | `"1"` | no | | region | Region where the instances should be created. | `string` | `null` | no | diff --git a/modules/compute_instance/versions.tf b/modules/compute_instance/versions.tf index 82eb623e..16a2787a 100644 --- a/modules/compute_instance/versions.tf +++ b/modules/compute_instance/versions.tf @@ -20,6 +20,6 @@ terraform { google = ">= 3.88, < 5.0" } provider_meta "google" { - module_name = "blueprints/terraform/terraform-google-vm:compute_instance/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:compute_instance/v9.0.0" } } diff --git a/modules/instance_template/README.md b/modules/instance_template/README.md index fbb6e0c9..12bcbeb1 100644 --- a/modules/instance_template/README.md +++ b/modules/instance_template/README.md @@ -15,7 +15,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example. |------|-------------|------|---------|:--------:| | access\_config | Access configurations, i.e. IPs via which the VM instance can be accessed via the Internet. |
list(object({
nat_ip = string
network_tier = string
}))
| `[]` | no | | additional\_disks | List of maps of additional disks. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#disk_name |
list(object({
disk_name = string
device_name = string
auto_delete = bool
boot = bool
disk_size_gb = number
disk_type = string
disk_labels = map(string)
}))
| `[]` | no | -| additional\_networks | Additional network interface details for GCE, if any. |
list(object({
network = string
subnetwork = string
subnetwork_project = string
network_ip = string
access_config = list(object({
nat_ip = string
network_tier = string
}))
ipv6_access_config = list(object({
network_tier = string
}))
}))
| `[]` | no | +| additional\_networks | Additional network interface details for GCE, if any. |
list(object({
network = string
subnetwork = string
subnetwork_project = string
network_ip = string
nic_type = string
stack_type = string
queue_count = number
access_config = list(object({
nat_ip = string
network_tier = string
}))
ipv6_access_config = list(object({
network_tier = string
}))
alias_ip_range = list(object({
ip_cidr_range = string
subnetwork_range_name = string
}))
}))
| `[]` | 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.
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.
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. |
object({
ip_cidr_range = string
subnetwork_range_name = string
})
| `null` | no | | auto\_delete | Whether or not the boot disk should be auto-deleted | `string` | `"true"` | no | | automatic\_restart | (Optional) Specifies whether the instance should be automatically restarted if it is terminated by Compute Engine (not terminated by a user). | `bool` | `true` | no | @@ -45,12 +45,14 @@ See the [simple](../../examples/instance_template/simple) for a usage example. | source\_image | Source disk image. If neither source\_image nor source\_image\_family is specified, defaults to the latest public CentOS image. | `string` | `""` | no | | source\_image\_family | Source image family. If neither source\_image nor source\_image\_family is specified, defaults to the latest public CentOS image. | `string` | `"centos-7"` | no | | source\_image\_project | Project where the source image comes from. The default project contains CentOS images. | `string` | `"centos-cloud"` | no | +| spot | Provision a SPOT instance | `bool` | `false` | no | | stack\_type | 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. | `string` | `null` | no | | startup\_script | User startup script to run when instances spin up | `string` | `""` | no | | subnetwork | The name of the subnetwork to attach this interface to. The subnetwork must exist in the same region this instance will be created in. Either network or subnetwork must be provided. | `string` | `""` | no | | subnetwork\_project | The ID of the project in which the subnetwork belongs. If it is not provided, the provider project is used. | `string` | `""` | no | | tags | Network tags, provided as a list | `list(string)` | `[]` | no | | threads\_per\_core | The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. | `number` | `null` | no | +| total\_egress\_bandwidth\_tier | Egress bandwidth tier setting for supported VM families | `string` | `"DEFAULT"` | no | ## Outputs diff --git a/modules/instance_template/main.tf b/modules/instance_template/main.tf index bd4a846e..a7ee69b5 100644 --- a/modules/instance_template/main.tf +++ b/modules/instance_template/main.tf @@ -45,13 +45,17 @@ locals { gpu_enabled = var.gpu != null alias_ip_range_enabled = var.alias_ip_range != null on_host_maintenance = ( - var.preemptible || var.enable_confidential_vm || local.gpu_enabled + var.preemptible || var.enable_confidential_vm || local.gpu_enabled || var.spot ? "TERMINATE" : var.on_host_maintenance ) automatic_restart = ( - # must be false when preemptible is true - var.preemptible ? false : var.automatic_restart + # must be false when preemptible or spot is true + var.preemptible || var.spot ? false : var.automatic_restart + ) + preemptible = ( + # must be true when preemtible or spot is true + var.preemptible || var.spot ? true : false ) } @@ -137,6 +141,9 @@ resource "google_compute_instance_template" "tpl" { subnetwork = network_interface.value.subnetwork subnetwork_project = network_interface.value.subnetwork_project network_ip = length(network_interface.value.network_ip) > 0 ? network_interface.value.network_ip : null + nic_type = network_interface.value.nic_type + stack_type = network_interface.value.stack_type + queue_count = network_interface.value.queue_count dynamic "access_config" { for_each = network_interface.value.access_config content { @@ -150,6 +157,13 @@ resource "google_compute_instance_template" "tpl" { network_tier = ipv6_access_config.value.network_tier } } + dynamic "alias_ip_range" { + for_each = network_interface.value.alias_ip_range + content { + ip_cidr_range = alias_ip_range.value.ip_cidr_range + subnetwork_range_name = alias_ip_range.value.subnetwork_range_name + } + } } } @@ -158,9 +172,11 @@ resource "google_compute_instance_template" "tpl" { } scheduling { - preemptible = var.preemptible - automatic_restart = local.automatic_restart - on_host_maintenance = local.on_host_maintenance + preemptible = local.preemptible + automatic_restart = local.automatic_restart + on_host_maintenance = local.on_host_maintenance + provisioning_model = var.spot ? "SPOT" : null + instance_termination_action = var.spot ? "STOP" : null } advanced_machine_features { @@ -181,6 +197,10 @@ resource "google_compute_instance_template" "tpl" { enable_confidential_compute = var.enable_confidential_vm } + network_performance_config { + total_egress_bandwidth_tier = var.total_egress_bandwidth_tier + } + dynamic "guest_accelerator" { for_each = local.gpu_enabled ? [var.gpu] : [] content { diff --git a/modules/instance_template/variables.tf b/modules/instance_template/variables.tf index c1072376..e7a3d34c 100644 --- a/modules/instance_template/variables.tf +++ b/modules/instance_template/variables.tf @@ -62,6 +62,12 @@ variable "preemptible" { default = false } +variable "spot" { + type = bool + description = "Provision a SPOT instance" + default = false +} + variable "automatic_restart" { type = bool description = "(Optional) Specifies whether the instance should be automatically restarted if it is terminated by Compute Engine (not terminated by a user)." @@ -198,6 +204,9 @@ variable "additional_networks" { subnetwork = string subnetwork_project = string network_ip = string + nic_type = string + stack_type = string + queue_count = number access_config = list(object({ nat_ip = string network_tier = string @@ -205,7 +214,39 @@ variable "additional_networks" { ipv6_access_config = list(object({ network_tier = string })) + alias_ip_range = list(object({ + ip_cidr_range = string + subnetwork_range_name = string + })) })) + validation { + condition = alltrue([ + for ni in var.additional_networks : (ni.network == null) != (ni.subnetwork == null) + ]) + error_message = "All additional network interfaces must define exactly one of \"network\" or \"subnetwork\"." + } + validation { + condition = alltrue([ + for ni in var.additional_networks : ni.nic_type == "GVNIC" || ni.nic_type == "VIRTIO_NET" || ni.nic_type == null + ]) + error_message = "In the variable additional_networks, field \"nic_type\" must be either \"GVNIC\", \"VIRTIO_NET\" or null." + } + validation { + condition = alltrue([ + for ni in var.additional_networks : ni.stack_type == "IPV4_ONLY" || ni.stack_type == "IPV4_IPV6" || ni.stack_type == null + ]) + error_message = "In the variable additional_networks, field \"stack_type\" must be either \"IPV4_ONLY\", \"IPV4_IPV6\" or null." + } +} + +variable "total_egress_bandwidth_tier" { + description = "Egress bandwidth tier setting for supported VM families" + type = string + default = "DEFAULT" + validation { + condition = contains(["DEFAULT", "TIER_1"], var.total_egress_bandwidth_tier) + error_message = "Allowed values for bandwidth_tier are 'DEFAULT' or 'TIER_1'." + } } ########### diff --git a/modules/instance_template/versions.tf b/modules/instance_template/versions.tf index 16fa675e..654c6b2f 100644 --- a/modules/instance_template/versions.tf +++ b/modules/instance_template/versions.tf @@ -17,9 +17,9 @@ terraform { required_version = ">=0.13.0" required_providers { - google = ">= 3.88, < 5.0" + google = ">= 4.67, < 5.0" } provider_meta "google" { - module_name = "blueprints/terraform/terraform-google-vm:instance_template/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:instance_template/v9.0.0" } } diff --git a/modules/mig/versions.tf b/modules/mig/versions.tf index 5e29f1ce..1e71e1b4 100644 --- a/modules/mig/versions.tf +++ b/modules/mig/versions.tf @@ -21,9 +21,9 @@ terraform { google-beta = ">= 4.48, < 5.0" } provider_meta "google" { - module_name = "blueprints/terraform/terraform-google-vm:mig/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:mig/v9.0.0" } provider_meta "google-beta" { - module_name = "blueprints/terraform/terraform-google-vm:mig/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:mig/v9.0.0" } } diff --git a/modules/mig_with_percent/versions.tf b/modules/mig_with_percent/versions.tf index 6c5986eb..c228f64f 100644 --- a/modules/mig_with_percent/versions.tf +++ b/modules/mig_with_percent/versions.tf @@ -21,9 +21,9 @@ terraform { google-beta = ">= 4.48, < 5.0" } provider_meta "google" { - module_name = "blueprints/terraform/terraform-google-vm:mig_with_percent/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:mig_with_percent/v9.0.0" } provider_meta "google-beta" { - module_name = "blueprints/terraform/terraform-google-vm:mig_with_percent/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:mig_with_percent/v9.0.0" } } diff --git a/modules/preemptible_and_regular_instance_templates/versions.tf b/modules/preemptible_and_regular_instance_templates/versions.tf index 5b8b0143..854c410b 100644 --- a/modules/preemptible_and_regular_instance_templates/versions.tf +++ b/modules/preemptible_and_regular_instance_templates/versions.tf @@ -21,9 +21,9 @@ terraform { google-beta = ">= 3.88, < 5.0" } provider_meta "google" { - module_name = "blueprints/terraform/terraform-google-vm:preemptible_and_regular_instance_templates/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:preemptible_and_regular_instance_templates/v9.0.0" } provider_meta "google-beta" { - module_name = "blueprints/terraform/terraform-google-vm:preemptible_and_regular_instance_templates/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:preemptible_and_regular_instance_templates/v9.0.0" } } diff --git a/modules/umig/versions.tf b/modules/umig/versions.tf index a86b2e34..efb8071f 100644 --- a/modules/umig/versions.tf +++ b/modules/umig/versions.tf @@ -20,6 +20,6 @@ terraform { google = ">= 3.88, < 5.0" } provider_meta "google" { - module_name = "blueprints/terraform/terraform-google-vm:umig/v8.0.1" + module_name = "blueprints/terraform/terraform-google-vm:umig/v9.0.0" } }