Skip to content

Commit

Permalink
Merge branch 'master' into infra-681/umig-zones
Browse files Browse the repository at this point in the history
  • Loading branch information
g-awmalik authored Sep 4, 2023
2 parents 2a4a49f + 6750fec commit e8d0a27
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 40 deletions.
37 changes: 19 additions & 18 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -45,20 +42,24 @@
},
{
"matchPackageNames": ["google", "google-beta"],
"groupName": "terraform googles"
"groupName": "Terraform Google Provider"
}
],
"regexManagers": [
{
"fileMatch": ["(^|/)Makefile$"],
"matchStrings": ["DOCKER_TAG_VERSION_DEVELOPER_TOOLS := (?<currentValue>.*?)\\n"],
"matchStrings": [
"DOCKER_TAG_VERSION_DEVELOPER_TOOLS := (?<currentValue>.*?)\\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: '(?<currentValue>.*?)'\\n"],
"matchStrings": [
" _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '(?<currentValue>.*?)'\\n"
],
"datasourceTemplate": "docker",
"registryUrlTemplate": "https://gcr.io/cloud-foundation-cicd",
"depNameTemplate": "cft/developer-tools"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ suites:
driver:
name: terraform
command_timeout: 1800
root_module_directory: test/fixtures/mig_with_percent/simple
root_module_directory: test/fixtures/mig_with_percent/simple
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions autogen/versions.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion examples/mig_stateful/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ module "mig" {
minimal_action = "REFRESH"
type = "OPPORTUNISTIC"
}]
}
}
2 changes: 1 addition & 1 deletion modules/compute_disk_snapshot/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
1 change: 1 addition & 0 deletions modules/compute_instance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | <pre>list(object({<br> network_tier = string<br> }))</pre> | `[]` | 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 |
Expand Down
2 changes: 1 addition & 1 deletion modules/compute_instance/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 3 additions & 1 deletion modules/instance_template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | <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> }))</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> 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> }))</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 |
| 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 |
Expand Down Expand Up @@ -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

Expand Down
32 changes: 26 additions & 6 deletions modules/instance_template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
}
}
}

Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
41 changes: 41 additions & 0 deletions modules/instance_template/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)."
Expand Down Expand Up @@ -198,14 +204,49 @@ 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
}))
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'."
}
}

###########
Expand Down
4 changes: 2 additions & 2 deletions modules/instance_template/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions modules/mig/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions modules/mig_with_percent/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion modules/umig/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit e8d0a27

Please sign in to comment.