diff --git a/.kitchen.yml b/.kitchen.yml
index a1211b0b..f5df34f8 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -15,6 +15,7 @@
---
driver:
name: terraform
+ verify_version: false
provisioner:
name: terraform
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f14f2804..8b8a551e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,68 @@
All notable changes to this project will be documented in this file. See [conventional-commits](https://www.conventionalcommits.org/) for commit guidelines.
+## [6.0.0](https://www.github.com/terraform-google-modules/terraform-google-vm/compare/v5.1.0...v6.0.0) (2020-12-08)
+
+
+### ⚠ BREAKING CHANGES
+
+* Minimum Terraform version increased to 0.13.
+* Update default source image and family to latest CentOS 7 (#126)
+
+### Features
+
+* add TF 0.13 constraint and module attribution ([#128](https://www.github.com/terraform-google-modules/terraform-google-vm/issues/128)) ([d042aae](https://www.github.com/terraform-google-modules/terraform-google-vm/commit/d042aae0ab50fbbe763ff551f3daa80aa8f1b551))
+* adds an output for the health check self_links to be consumed by load balancer resources outside this module ([#119](https://www.github.com/terraform-google-modules/terraform-google-vm/issues/119)) ([ae4d777](https://www.github.com/terraform-google-modules/terraform-google-vm/commit/ae4d7777958fe4238d96191a3aa7c7deab996fd1))
+* Update default source image and family to latest CentOS 7 ([#126](https://www.github.com/terraform-google-modules/terraform-google-vm/issues/126)) ([6310016](https://www.github.com/terraform-google-modules/terraform-google-vm/commit/63100169ebecea163f3965f4be3df8b600af047d))
+
+## [5.1.0](https://www.github.com/terraform-google-modules/terraform-google-vm/compare/v5.0.0...v5.1.0) (2020-10-07)
+
+
+### Features
+
+* Added instance_group_manager output ([#105](https://www.github.com/terraform-google-modules/terraform-google-vm/issues/105)) ([e8a174a](https://www.github.com/terraform-google-modules/terraform-google-vm/commit/e8a174aa899f9ade792d1576689603eab6ca774e))
+
+## [5.0.0](https://www.github.com/terraform-google-modules/terraform-google-vm/compare/v4.0.0...v5.0.0) (2020-09-15)
+
+
+### ⚠ BREAKING CHANGES
+
+* **UMIG:** var.access_config has been changed to a 2D array, with a separate element for each VM.
+
+### Bug Fixes
+
+* **UMIG:** access_config should be 2D array ([#111](https://www.github.com/terraform-google-modules/terraform-google-vm/issues/111)) ([69f7520](https://www.github.com/terraform-google-modules/terraform-google-vm/commit/69f752033453ceb2ee50a8d5614112ce96b60650))
+* relax version constraints to enable terraform 0.13.x compatibility ([#108](https://www.github.com/terraform-google-modules/terraform-google-vm/issues/108)) ([6fb2b42](https://www.github.com/terraform-google-modules/terraform-google-vm/commit/6fb2b42bd96f90d3c2baffd511cb58200fbc074c))
+* Terraform version upgrade for compute_instance module from 0.12.6 to 0.12.7 ([#103](https://www.github.com/terraform-google-modules/terraform-google-vm/issues/103)) ([7a21e78](https://www.github.com/terraform-google-modules/terraform-google-vm/commit/7a21e788f6ded801be8d3354bfd31934aca5b7fb))
+
+## [4.0.0](https://www.github.com/terraform-google-modules/terraform-google-vm/compare/v3.0.0...v4.0.0) (2020-06-23)
+
+
+### ⚠ BREAKING CHANGES
+
+* instance_redistribution_type must now be specified for update policies.
+
+### Features
+
+* Add stateful disk support ([#90](https://www.github.com/terraform-google-modules/terraform-google-vm/issues/90)) ([645e845](https://www.github.com/terraform-google-modules/terraform-google-vm/commit/645e8453e945fe6f7b1c5cccd7ad557f5355cc10))
+* Add wait_for_instances and configurable timeout support for mig ([#96](https://www.github.com/terraform-google-modules/terraform-google-vm/issues/96)) ([10a23b7](https://www.github.com/terraform-google-modules/terraform-google-vm/commit/10a23b70250bd26ed9820184b535e4ce99d24ec7))
+
+## [3.0.0](https://www.github.com/terraform-google-modules/terraform-google-vm/compare/v2.1.0...v3.0.0) (2020-05-27)
+
+
+### ⚠ BREAKING CHANGES
+
+* The preemptible_and_regular_instance_templates modules have had name_prefixes renamed, forcing instances to be recreated.
+
+### Features
+
+* Add support for assigning public IPs directly to instances. ([#83](https://www.github.com/terraform-google-modules/terraform-google-vm/issues/83)) ([dde01ff](https://www.github.com/terraform-google-modules/terraform-google-vm/commit/dde01ff376a8e58b4a365724cb4531a4e24435a5))
+
+
+### Bug Fixes
+
+* Correct names for instances in preemptible and regular instance module ([#81](https://www.github.com/terraform-google-modules/terraform-google-vm/issues/81)) ([5a6ec12](https://www.github.com/terraform-google-modules/terraform-google-vm/commit/5a6ec12c3d26c88e45fe4b1a1d919562b4995f24))
+
## [2.1.0](https://www.github.com/terraform-google-modules/terraform-google-vm/compare/v2.0.0...v2.1.0) (2020-03-05)
diff --git a/Makefile b/Makefile
index ce33b2d5..38654e2e 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@
# Make will use bash instead of sh
SHELL := /usr/bin/env bash
-DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0
+DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.13
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd
diff --git a/README.md b/README.md
index 5a289cf5..85463b18 100644
--- a/README.md
+++ b/README.md
@@ -8,9 +8,9 @@ This is a collection of opinionated submodules that can be used as building bloc
## Compatibility
- This module is meant for use with Terraform 0.12. If you haven't [upgraded](https://www.terraform.io/upgrade-guides/0-12.html)
- and need a Terraform 0.11.x-compatible version of this module, the last released version intended for
- Terraform 0.11.x is [0.2.0](https://registry.terraform.io/modules/terraform-google-modules/vm/google/0.2.0).
+ This module is meant for use with Terraform 0.13. If you haven't [upgraded](https://www.terraform.io/upgrade-guides/0-13.html)
+ and need a Terraform 0.12.x-compatible version of this module, the last released version intended for
+ Terraform 0.12.x is [5.1.0](https://registry.terraform.io/modules/terraform-google-modules/vm/google/5.1.0).
## Examples
diff --git a/autogen/main.tf.tmpl b/autogen/main.tf.tmpl
index 32666474..ce571f40 100644
--- a/autogen/main.tf.tmpl
+++ b/autogen/main.tf.tmpl
@@ -29,12 +29,8 @@ locals {
}
data "google_compute_zones" "available" {
- {% if mig %}
project = var.project_id
region = var.region
- {% else %}
- region = var.region
- {% endif %}
}
resource "google_compute_region_instance_group_manager" "{{ module_name }}" {
@@ -75,6 +71,8 @@ resource "google_compute_region_instance_group_manager" "{{ module_name }}" {
target_pools = var.target_pools
target_size = var.autoscaling_enabled ? null : var.target_size
+ wait_for_instances = var.wait_for_instances
+
dynamic "auto_healing_policies" {
for_each = local.healthchecks
content {
@@ -83,17 +81,26 @@ resource "google_compute_region_instance_group_manager" "{{ module_name }}" {
}
}
+ dynamic "stateful_disk" {
+ for_each = var.stateful_disks
+ content {
+ device_name = stateful_disk.value.device_name
+ delete_rule = lookup(stateful_disk.value, "delete_rule", null)
+ }
+ }
+
distribution_policy_zones = local.distribution_policy_zones
dynamic "update_policy" {
for_each = var.update_policy
content {
- 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)
- 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)
+ minimal_action = update_policy.value.minimal_action
+ type = update_policy.value.type
}
}
@@ -101,6 +108,12 @@ resource "google_compute_region_instance_group_manager" "{{ module_name }}" {
create_before_destroy = true
ignore_changes = [distribution_policy_zones]
}
+
+ timeouts {
+ create = var.mig_timeouts.create
+ update = var.mig_timeouts.update
+ delete = var.mig_timeouts.delete
+ }
}
resource "google_compute_region_autoscaler" "autoscaler" {
@@ -108,10 +121,9 @@ resource "google_compute_region_autoscaler" "autoscaler" {
count = var.autoscaling_enabled ? 1 : 0
name = "${var.hostname}-autoscaler"
project = var.project_id
- {% if mig %}
region = var.region
- {% endif %}
- target = google_compute_region_instance_group_manager.{{ module_name }}.self_link
+
+ target = google_compute_region_instance_group_manager.{{ module_name }}.self_link
autoscaling_policy {
max_replicas = var.max_replicas
@@ -140,7 +152,7 @@ resource "google_compute_region_autoscaler" "autoscaler" {
}
{% if mig_with_percent %}
- depends_on = ["google_compute_region_instance_group_manager.mig_with_percent"]
+ depends_on = [google_compute_region_instance_group_manager.mig_with_percent]
{% endif %}
}
diff --git a/autogen/outputs.tf.tmpl b/autogen/outputs.tf.tmpl
index b343c8d6..a0e36355 100644
--- a/autogen/outputs.tf.tmpl
+++ b/autogen/outputs.tf.tmpl
@@ -25,3 +25,13 @@ output "instance_group" {
description = "Instance-group url of managed instance group"
value = google_compute_region_instance_group_manager.{{ module_name }}.instance_group
}
+
+output "instance_group_manager" {
+ description = "An instance of google_compute_region_instance_group_manager of the instance group."
+ value = google_compute_region_instance_group_manager.{{ module_name }}
+}
+
+output "health_check_self_links" {
+ description = "All self_links of healthchecks created for the instance group."
+ value = local.healthchecks
+}
diff --git a/autogen/variables.tf.tmpl b/autogen/variables.tf.tmpl
index c513552d..9ebca12e 100644
--- a/autogen/variables.tf.tmpl
+++ b/autogen/variables.tf.tmpl
@@ -67,6 +67,18 @@ variable "distribution_policy_zones" {
default = []
}
+#################
+# Stateful disks
+#################
+variable "stateful_disks" {
+ description = "Disks created on the instances that will be preserved on instance delete. https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-disks-in-migs"
+ type = list(object({
+ device_name = string
+ delete_rule = string
+ }))
+ default = []
+}
+
#################
# Rolling Update
#################
@@ -74,13 +86,14 @@ 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.html#rolling_update_policy"
type = list(object({
- max_surge_fixed = number
- max_surge_percent = number
- max_unavailable_fixed = number
- max_unavailable_percent = number
- min_ready_sec = number
- 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
+ minimal_action = string
+ type = string
}))
default = []
}
@@ -191,3 +204,22 @@ variable "named_ports" {
}))
default = []
}
+
+variable "wait_for_instances" {
+ description = "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."
+ default = "false"
+}
+
+variable "mig_timeouts" {
+ description = "Times for creation, deleting and updating the MIG resources. Can be helpful when using wait_for_instances to allow a longer VM startup time. "
+ type = object({
+ create = string
+ update = string
+ delete = string
+ })
+ default = {
+ create = "5m"
+ update = "5m"
+ delete = "15m"
+ }
+}
diff --git a/autogen/versions.tf b/autogen/versions.tf.tmpl
similarity index 60%
rename from autogen/versions.tf
rename to autogen/versions.tf.tmpl
index 37b48316..e488220d 100644
--- a/autogen/versions.tf
+++ b/autogen/versions.tf.tmpl
@@ -15,9 +15,15 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.13.0"
required_providers {
- google = ">= 2.7, <4.0"
- google-beta = ">= 2.7, <4.0"
+ google = ">= 3.43, <4.0"
+ google-beta = ">= 3.43, <4.0"
+ }
+ provider_meta "google" {
+ module_name = "blueprints/terraform/terraform-google-vm:{% if mig %}mig{% else %}mig_with_percent{% endif %}/v6.0.0"
+ }
+ provider_meta "google-beta" {
+ module_name = "blueprints/terraform/terraform-google-vm:{% if mig %}mig{% else %}mig_with_percent{% endif %}/v6.0.0"
}
}
diff --git a/build/int.cloudbuild.yaml b/build/int.cloudbuild.yaml
index 5008c963..bfa419cf 100644
--- a/build/int.cloudbuild.yaml
+++ b/build/int.cloudbuild.yaml
@@ -246,4 +246,4 @@ tags:
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
- _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0'
+ _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
diff --git a/build/lint.cloudbuild.yaml b/build/lint.cloudbuild.yaml
index bd8cdc27..7c1aecbc 100644
--- a/build/lint.cloudbuild.yaml
+++ b/build/lint.cloudbuild.yaml
@@ -21,4 +21,4 @@ tags:
- 'lint'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
- _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0'
+ _DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
diff --git a/examples/compute_instance/simple/README.md b/examples/compute_instance/simple/README.md
index 2796d70d..114f1971 100644
--- a/examples/compute_instance/simple/README.md
+++ b/examples/compute_instance/simple/README.md
@@ -6,12 +6,14 @@ This is a simple, minimal example of how to use the compute_instance module
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| num\_instances | Number of instances to create | string | n/a | yes |
-| project\_id | The GCP project to use for integration tests | string | n/a | yes |
-| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
-| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
-| subnetwork | The subnetwork selflink to host the compute instances in | string | n/a | yes |
+|------|-------------|------|---------|:--------:|
+| nat\_ip | Public ip address | `any` | `null` | no |
+| network\_tier | Network network\_tier | `string` | `"PREMIUM"` | no |
+| num\_instances | Number of instances to create | `any` | n/a | yes |
+| project\_id | The GCP project to use for integration tests | `string` | n/a | yes |
+| region | The GCP region to create and test resources in | `string` | `"us-central1"` | no |
+| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. |
object({
email = string,
scopes = set(string)
})
| `null` | no |
+| subnetwork | The subnetwork selflink to host the compute instances in | `any` | n/a | yes |
## Outputs
diff --git a/examples/compute_instance/simple/main.tf b/examples/compute_instance/simple/main.tf
index 5416b1bf..1aed75d6 100644
--- a/examples/compute_instance/simple/main.tf
+++ b/examples/compute_instance/simple/main.tf
@@ -34,4 +34,8 @@ module "compute_instance" {
num_instances = var.num_instances
hostname = "instance-simple"
instance_template = module.instance_template.self_link
+ access_config = [{
+ nat_ip = var.nat_ip
+ network_tier = var.network_tier
+ }, ]
}
diff --git a/examples/compute_instance/simple/variables.tf b/examples/compute_instance/simple/variables.tf
index 87fc129a..6f10f6dc 100644
--- a/examples/compute_instance/simple/variables.tf
+++ b/examples/compute_instance/simple/variables.tf
@@ -35,6 +35,15 @@ variable "num_instances" {
description = "Number of instances to create"
}
+variable "nat_ip" {
+ description = "Public ip address"
+ default = null
+}
+
+variable "network_tier" {
+ description = "Network network_tier"
+ default = "PREMIUM"
+}
variable "service_account" {
diff --git a/examples/compute_instance/simple/versions.tf b/examples/compute_instance/simple/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/compute_instance/simple/versions.tf
+++ b/examples/compute_instance/simple/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/examples/instance_template/additional_disks/README.md b/examples/instance_template/additional_disks/README.md
index 05ebed3f..37f4ae03 100644
--- a/examples/instance_template/additional_disks/README.md
+++ b/examples/instance_template/additional_disks/README.md
@@ -7,11 +7,11 @@ instance templates with additional persistent disks.
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| project\_id | The GCP project to use for integration tests | string | n/a | yes |
-| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
-| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
-| subnetwork | The name of the subnetwork create this instance in. | string | `""` | no |
+|------|-------------|------|---------|:--------:|
+| project\_id | The GCP project to use for integration tests | `string` | n/a | yes |
+| region | The GCP region to create and test resources in | `string` | `"us-central1"` | no |
+| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object({
email = string
scopes = set(string)
})
| `null` | no |
+| subnetwork | The name of the subnetwork create this instance in. | `string` | `""` | no |
## Outputs
diff --git a/examples/instance_template/additional_disks/versions.tf b/examples/instance_template/additional_disks/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/instance_template/additional_disks/versions.tf
+++ b/examples/instance_template/additional_disks/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/examples/instance_template/simple/README.md b/examples/instance_template/simple/README.md
index 56d19aea..82cfe298 100644
--- a/examples/instance_template/simple/README.md
+++ b/examples/instance_template/simple/README.md
@@ -6,13 +6,13 @@ This is a simple, minimal example of how to use the instance_template module.
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| labels | Labels, provided as a map | map(string) | n/a | yes |
-| project\_id | The GCP project to use for integration tests | string | n/a | yes |
-| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
-| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
-| subnetwork | The name of the subnetwork create this instance in. | string | `""` | no |
-| tags | Network tags, provided as a list | list(string) | n/a | yes |
+|------|-------------|------|---------|:--------:|
+| labels | Labels, provided as a map | `map(string)` | n/a | yes |
+| project\_id | The GCP project to use for integration tests | `string` | n/a | yes |
+| region | The GCP region to create and test resources in | `string` | `"us-central1"` | no |
+| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object({
email = string
scopes = set(string)
})
| `null` | no |
+| subnetwork | The name of the subnetwork create this instance in. | `string` | `""` | no |
+| tags | Network tags, provided as a list | `list(string)` | n/a | yes |
## Outputs
diff --git a/examples/instance_template/simple/versions.tf b/examples/instance_template/simple/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/instance_template/simple/versions.tf
+++ b/examples/instance_template/simple/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/examples/mig/autoscaler/README.md b/examples/mig/autoscaler/README.md
index dac2fbd7..d37dad7f 100644
--- a/examples/mig/autoscaler/README.md
+++ b/examples/mig/autoscaler/README.md
@@ -7,14 +7,14 @@ group with an autoscaler.
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization | list(map(number)) | n/a | yes |
-| autoscaling\_enabled | Creates an autoscaler for the managed instance group | string | n/a | yes |
-| min\_replicas | The minimum number of replicas that the autoscaler can scale down to. This cannot be less than 0. | string | n/a | yes |
-| project\_id | The GCP project to use for integration tests | string | n/a | yes |
-| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
-| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
-| subnetwork | The subnetwork to host the compute instances in | string | n/a | yes |
+|------|-------------|------|---------|:--------:|
+| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization | `list(map(number))` | n/a | yes |
+| autoscaling\_enabled | Creates an autoscaler for the managed instance group | `any` | n/a | yes |
+| min\_replicas | The minimum number of replicas that the autoscaler can scale down to. This cannot be less than 0. | `any` | n/a | yes |
+| project\_id | The GCP project to use for integration tests | `string` | n/a | yes |
+| region | The GCP region to create and test resources in | `string` | `"us-central1"` | no |
+| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object({
email = string
scopes = set(string)
})
| `null` | no |
+| subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes |
## Outputs
diff --git a/examples/mig/autoscaler/versions.tf b/examples/mig/autoscaler/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/mig/autoscaler/versions.tf
+++ b/examples/mig/autoscaler/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/examples/mig/full/variables.tf b/examples/mig/full/variables.tf
index 3ee450db..4bf8275b 100644
--- a/examples/mig/full/variables.tf
+++ b/examples/mig/full/variables.tf
@@ -179,13 +179,14 @@ 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.html#rolling_update_policy"
type = list(object({
- max_surge_fixed = number
- max_surge_percent = number
- max_unavailable_fixed = number
- max_unavailable_percent = number
- min_ready_sec = number
- 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
+ minimal_action = string
+ type = string
}))
default = []
}
@@ -268,4 +269,3 @@ variable "autoscaling_enabled" {
type = bool
default = false
}
-
diff --git a/examples/mig/full/versions.tf b/examples/mig/full/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/mig/full/versions.tf
+++ b/examples/mig/full/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/examples/mig/simple/README.md b/examples/mig/simple/README.md
index d0250dd7..6d61fead 100644
--- a/examples/mig/simple/README.md
+++ b/examples/mig/simple/README.md
@@ -7,12 +7,12 @@ managed instance group.
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| project\_id | The GCP project to use for integration tests | string | n/a | yes |
-| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
-| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
-| subnetwork | The subnetwork to host the compute instances in | string | n/a | yes |
-| 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. | string | n/a | yes |
+|------|-------------|------|---------|:--------:|
+| project\_id | The GCP project to use for integration tests | `string` | n/a | yes |
+| region | The GCP region to create and test resources in | `string` | `"us-central1"` | no |
+| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object({
email = string
scopes = set(string)
})
| `null` | no |
+| subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes |
+| 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. | `any` | n/a | yes |
## Outputs
diff --git a/examples/mig/simple/versions.tf b/examples/mig/simple/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/mig/simple/versions.tf
+++ b/examples/mig/simple/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/examples/mig_with_percent/simple/README.md b/examples/mig_with_percent/simple/README.md
index 297de5b1..0d3bf799 100644
--- a/examples/mig_with_percent/simple/README.md
+++ b/examples/mig_with_percent/simple/README.md
@@ -7,11 +7,11 @@ managed instance group.
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| project\_id | The GCP project to use for integration tests | string | n/a | yes |
-| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
-| service\_account | Service account email address and scopes | object | `"null"` | no |
-| subnetwork | The subnetwork to host the compute instances in | string | n/a | yes |
+|------|-------------|------|---------|:--------:|
+| project\_id | The GCP project to use for integration tests | `string` | n/a | yes |
+| region | The GCP region to create and test resources in | `string` | `"us-central1"` | no |
+| service\_account | Service account email address and scopes | object({
email = string
scopes = set(string)
})
| `null` | no |
+| subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes |
## Outputs
diff --git a/examples/mig_with_percent/simple/versions.tf b/examples/mig_with_percent/simple/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/mig_with_percent/simple/versions.tf
+++ b/examples/mig_with_percent/simple/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/examples/preemptible_and_regular_instance_templates/simple/README.md b/examples/preemptible_and_regular_instance_templates/simple/README.md
index e57bfa50..f8441668 100644
--- a/examples/preemptible_and_regular_instance_templates/simple/README.md
+++ b/examples/preemptible_and_regular_instance_templates/simple/README.md
@@ -6,13 +6,13 @@ This creates instance templates for both preemptible VM and regular VM
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| labels | Labels, provided as a map | map(string) | n/a | yes |
-| project\_id | The GCP project to use for integration tests | string | n/a | yes |
-| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
-| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
-| subnetwork | The name of the subnetwork create this instance in. | string | `""` | no |
-| tags | Network tags, provided as a list | list(string) | n/a | yes |
+|------|-------------|------|---------|:--------:|
+| labels | Labels, provided as a map | `map(string)` | n/a | yes |
+| project\_id | The GCP project to use for integration tests | `string` | n/a | yes |
+| region | The GCP region to create and test resources in | `string` | `"us-central1"` | no |
+| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object({
email = string
scopes = set(string)
})
| `null` | no |
+| subnetwork | The name of the subnetwork create this instance in. | `string` | `""` | no |
+| tags | Network tags, provided as a list | `list(string)` | n/a | yes |
## Outputs
diff --git a/examples/preemptible_and_regular_instance_templates/simple/versions.tf b/examples/preemptible_and_regular_instance_templates/simple/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/preemptible_and_regular_instance_templates/simple/versions.tf
+++ b/examples/preemptible_and_regular_instance_templates/simple/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/examples/umig/full/main.tf b/examples/umig/full/main.tf
index 0350f9ad..eebdd5f5 100644
--- a/examples/umig/full/main.tf
+++ b/examples/umig/full/main.tf
@@ -73,5 +73,5 @@ module "umig" {
instance_template = module.instance_template.self_link
named_ports = var.named_ports
region = var.region
- access_config = [local.access_config]
+ access_config = [[local.access_config]]
}
diff --git a/examples/umig/full/versions.tf b/examples/umig/full/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/umig/full/versions.tf
+++ b/examples/umig/full/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/examples/umig/named_ports/README.md b/examples/umig/named_ports/README.md
index 9fb0d029..f1893fdd 100644
--- a/examples/umig/named_ports/README.md
+++ b/examples/umig/named_ports/README.md
@@ -7,13 +7,13 @@ groups with named ports
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| named\_ports | Named name and named port | object | `` | no |
-| num\_instances | Number of instances to create | string | n/a | yes |
-| project\_id | The GCP project to use for integration tests | string | n/a | yes |
-| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
-| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
-| subnetwork | The subnetwork to host the compute instances in | string | n/a | yes |
+|------|-------------|------|---------|:--------:|
+| named\_ports | Named name and named port | list(object({
name = string
port = number
}))
| `[]` | no |
+| num\_instances | Number of instances to create | `any` | n/a | yes |
+| project\_id | The GCP project to use for integration tests | `string` | n/a | yes |
+| region | The GCP region to create and test resources in | `string` | `"us-central1"` | no |
+| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object({
email = string
scopes = set(string)
})
| `null` | no |
+| subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes |
## Outputs
diff --git a/examples/umig/named_ports/versions.tf b/examples/umig/named_ports/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/umig/named_ports/versions.tf
+++ b/examples/umig/named_ports/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/examples/umig/simple/README.md b/examples/umig/simple/README.md
index cced24a6..36b68aa7 100644
--- a/examples/umig/simple/README.md
+++ b/examples/umig/simple/README.md
@@ -6,12 +6,12 @@ This is a simple, minimal example of how to use the UMIG module
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| num\_instances | Number of instances to create | string | n/a | yes |
-| project\_id | The GCP project to use for integration tests | string | n/a | yes |
-| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
-| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
-| subnetwork | The subnetwork to host the compute instances in | string | n/a | yes |
+|------|-------------|------|---------|:--------:|
+| num\_instances | Number of instances to create | `any` | n/a | yes |
+| project\_id | The GCP project to use for integration tests | `string` | n/a | yes |
+| region | The GCP region to create and test resources in | `string` | `"us-central1"` | no |
+| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object({
email = string
scopes = set(string)
})
| `null` | no |
+| subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes |
## Outputs
diff --git a/examples/umig/simple/versions.tf b/examples/umig/simple/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/umig/simple/versions.tf
+++ b/examples/umig/simple/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/examples/umig/static_ips/README.md b/examples/umig/static_ips/README.md
index d4ea211d..ea6c1554 100644
--- a/examples/umig/static_ips/README.md
+++ b/examples/umig/static_ips/README.md
@@ -7,13 +7,13 @@ instance groups with user-specified static IPs.
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| num\_instances | Number of instances to create | string | `"1"` | no |
-| project\_id | The GCP project to use for integration tests | string | n/a | yes |
-| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
-| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
-| static\_ips | List of static IPs for VM instances | list(string) | n/a | yes |
-| subnetwork | The subnetwork to host the compute instances in | string | n/a | yes |
+|------|-------------|------|---------|:--------:|
+| num\_instances | Number of instances to create | `string` | `"1"` | no |
+| project\_id | The GCP project to use for integration tests | `string` | n/a | yes |
+| region | The GCP region to create and test resources in | `string` | `"us-central1"` | no |
+| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object({
email = string
scopes = set(string)
})
| `null` | no |
+| static\_ips | List of static IPs for VM instances | `list(string)` | n/a | yes |
+| subnetwork | The subnetwork to host the compute instances in | `any` | n/a | yes |
## Outputs
diff --git a/examples/umig/static_ips/versions.tf b/examples/umig/static_ips/versions.tf
index 1a9363a3..fb3fee63 100644
--- a/examples/umig/static_ips/versions.tf
+++ b/examples/umig/static_ips/versions.tf
@@ -15,5 +15,5 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.12.6"
}
diff --git a/modules/compute_instance/README.md b/modules/compute_instance/README.md
index 8fde7124..6f8cbf21 100644
--- a/modules/compute_instance/README.md
+++ b/modules/compute_instance/README.md
@@ -5,7 +5,7 @@ This module is used to create compute instances (and only compute instances) usi
## Usage
-See the [simple](examples/compute_instance/simple) for a usage example.
+See the [simple](https://github.com/terraform-google-modules/terraform-google-vm/tree/master/examples/compute_instance/simple) for a usage example.
## Testing
@@ -14,15 +14,16 @@ See the [simple](examples/compute_instance/simple) for a usage example.
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| hostname | Hostname of instances | string | `""` | no |
-| instance\_template | Instance template self_link used to create compute instances | string | n/a | yes |
-| 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. | string | `"1"` | no |
-| region | Region where the instances should be created. | string | `"null"` | no |
-| static\_ips | List of static IPs for VM instances | list(string) | `` | no |
-| subnetwork | Subnet to deploy to. Only one of network or subnetwork should be specified. | string | `""` | no |
-| subnetwork\_project | The project that subnetwork belongs to | string | `""` | no |
+|------|-------------|------|---------|:--------:|
+| 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 |
+| hostname | Hostname of instances | `string` | `""` | no |
+| instance\_template | Instance template self\_link used to create compute instances | `any` | n/a | yes |
+| 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. | `string` | `"1"` | no |
+| region | Region where the instances should be created. | `string` | `null` | no |
+| static\_ips | List of static IPs for VM instances | `list(string)` | `[]` | no |
+| subnetwork | Subnet to deploy to. Only one of network or subnetwork should be specified. | `string` | `""` | no |
+| subnetwork\_project | The project that subnetwork belongs to | `string` | `""` | no |
## Outputs
diff --git a/modules/compute_instance/main.tf b/modules/compute_instance/main.tf
index f2e86744..c6a4476b 100644
--- a/modules/compute_instance/main.tf
+++ b/modules/compute_instance/main.tf
@@ -50,6 +50,13 @@ resource "google_compute_instance_from_template" "compute_instance" {
subnetwork = var.subnetwork
subnetwork_project = var.subnetwork_project
network_ip = length(var.static_ips) == 0 ? "" : element(local.static_ips, count.index)
+ dynamic "access_config" {
+ for_each = var.access_config
+ content {
+ nat_ip = access_config.value.nat_ip
+ network_tier = access_config.value.network_tier
+ }
+ }
}
source_instance_template = var.instance_template
diff --git a/modules/compute_instance/variables.tf b/modules/compute_instance/variables.tf
index 7d20e4ba..1f2e8c7e 100644
--- a/modules/compute_instance/variables.tf
+++ b/modules/compute_instance/variables.tf
@@ -40,6 +40,15 @@ variable "static_ips" {
default = []
}
+variable "access_config" {
+ description = "Access configurations, i.e. IPs via which the VM instance can be accessed via the Internet."
+ type = list(object({
+ nat_ip = string
+ network_tier = string
+ }))
+ default = []
+}
+
variable "num_instances" {
description = "Number of instances to create. This value is ignored if static_ips is provided."
default = "1"
diff --git a/modules/compute_instance/versions.tf b/modules/compute_instance/versions.tf
index fb32dd3f..09c274e0 100644
--- a/modules/compute_instance/versions.tf
+++ b/modules/compute_instance/versions.tf
@@ -15,8 +15,11 @@
*/
terraform {
- required_version = "~> 0.12.6"
+ required_version = ">=0.13.0"
required_providers {
- google = ">= 2.7, <4.0"
+ google = ">= 3.43, <4.0"
+ }
+ provider_meta "google" {
+ module_name = "blueprints/terraform/terraform-google-vm:compute_instance/v6.0.0"
}
}
diff --git a/modules/instance_template/README.md b/modules/instance_template/README.md
index bdccf0d7..720f2946 100644
--- a/modules/instance_template/README.md
+++ b/modules/instance_template/README.md
@@ -1,6 +1,6 @@
# instance_template
-This submodule allows you to create an `google_compute_instance_template`
+This submodule allows you to create a `google_compute_instance_template`
resource, which is used as the basis for the other instance, managed, and
unmanaged instance groups submodules.
@@ -14,31 +14,31 @@ See the [simple](../../examples/instance_template/simple) for a usage example.
## Inputs
| Name | Description | Type | Default | Required |
-|------|-------------|:----:|:-----:|:-----:|
-| access\_config | Access configurations, i.e. IPs via which the VM instance can be accessed via the Internet. | object | `` | no |
-| additional\_disks | List of maps of additional disks. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#disk_name | object | `` | no |
-| auto\_delete | Whether or not the boot disk should be auto-deleted | string | `"true"` | no |
-| can\_ip\_forward | Enable IP forwarding, for NAT instances for example | string | `"false"` | 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\_shielded\_vm | Whether to enable the Shielded VM configuration on the instance. Note that the instance image must support Shielded VMs. See https://cloud.google.com/compute/docs/images | string | `"false"` | no |
-| labels | Labels, provided as a map | map(string) | `