Skip to content

Commit

Permalink
DEVOPS-1842 Merge master into branch "instance-template/disk-variable…
Browse files Browse the repository at this point in the history
…s" for TF v0.13 support (#2)

* fix: Correct names for instances in preemptible and regular instance module (terraform-google-modules#81)

BREAKING CHANGE: The preemptible_and_regular_instance_templates modules have had name_prefixes renamed, forcing instances to be recreated.

* chore: fixing typo in instance_template README (terraform-google-modules#86)

* feat: Add support for assigning public IPs directly to instances. (terraform-google-modules#83)

* chore: release 3.0.0 (terraform-google-modules#82)

* updated CHANGELOG.md [ci skip]

* updated README.md

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>

* fix terraform-google-modules#88 issues with autogen tmpl for mig (terraform-google-modules#93)

* chore: fix format

* feat: Add stateful disk support (terraform-google-modules#90)

* Added: stateful configuration

* Added: var udpate

* Added: var udpate

* Updated: stateful_disk variable, autogen docs

* feat: Add wait_for_instances and configurable timeout support for mig (terraform-google-modules#96)

BREAKING CHANGE: instance_redistribution_type must now be specified for update policies.

* chore: release 4.0.0 (terraform-google-modules#98)

* fix: relax version constraints to enable terraform 0.13.x compatibility (terraform-google-modules#108)

* chore: Updating Links in README (terraform-google-modules#97) (terraform-google-modules#112)

* Update README.md

* Update README.md

* fix: Terraform version upgrade for compute_instance module from 0.12.6 to 0.12.7 (terraform-google-modules#103)

* fix(UMIG): access_config should be 2D array (terraform-google-modules#111)

BREAKING CHANGE: var.access_config has been changed to a 2D array, with a separate element for each VM.

* chore: release 5.0.0

* feat: Added instance_group_manager output (terraform-google-modules#105)

* add instance_group_manager output

needed to create a stateful MIG in conjunction with https://www.terraform.io/docs/providers/google/r/compute_region_per_instance_config.html

* fix: autogen/outputs.tf.tmpl use {{ module_name }} in instance_group_manager output

Co-authored-by: Morgante Pell <[email protected]>

* chore: release 5.1.0 (terraform-google-modules#115)

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>

* feat: adds an output for the health check self_links to be consumed by load balancer resources outside this module (terraform-google-modules#119)

* feat: adds an output for the health check self_links to be consumed by load balancer resources outside this module

* chore: docs generation

* moved change up to autogen

* aligning CI and makefile image for docs generation

* feat!: Update default source image and family to latest CentOS 7 (terraform-google-modules#126)

* feat: add TF 0.13 constraint and module attribution (terraform-google-modules#128)

BREAKING CHANGE: Minimum Terraform version increased to 0.13.

* chore: Remove < 0.14 constraints in examples/fixtures [bot-pr] (terraform-google-modules#129)

* chore: release 6.0.0 (terraform-google-modules#127)

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>

Co-authored-by: GeneralAardvark <[email protected]>
Co-authored-by: fclerg <[email protected]>
Co-authored-by: Richard Chen Zheng <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Pasquale D'Agostino <[email protected]>
Co-authored-by: Morgante Pell <[email protected]>
Co-authored-by: Konstantin Kirpichnikov <[email protected]>
Co-authored-by: Sean Johnson <[email protected]>
Co-authored-by: Brandon J. Bjelland <[email protected]>
Co-authored-by: Darpan Shah <[email protected]>
Co-authored-by: Aaron Yang <[email protected]>
Co-authored-by: Uroš <[email protected]>
Co-authored-by: Ryan Canty <[email protected]>
Co-authored-by: Adrian <[email protected]>
Co-authored-by: Brandon J. Bjelland <[email protected]>
Co-authored-by: Yurii Serhiichuk <[email protected]>
Co-authored-by: Bharath KKB <[email protected]>
Co-authored-by: cloud-foundation-bot <[email protected]>
  • Loading branch information
19 people authored Feb 25, 2021
1 parent 037ea1b commit 04f7441
Show file tree
Hide file tree
Showing 73 changed files with 623 additions and 303 deletions.
1 change: 1 addition & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
---
driver:
name: terraform
verify_version: false

provisioner:
name: terraform
Expand Down
62 changes: 62 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
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 := 0
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.13
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 27 additions & 15 deletions autogen/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}" {
Expand Down Expand Up @@ -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 {
Expand All @@ -83,35 +81,49 @@ 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
}
}

lifecycle {
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" {
provider = google
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
Expand Down Expand Up @@ -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 %}
}

Expand Down
10 changes: 10 additions & 0 deletions autogen/outputs.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
46 changes: 39 additions & 7 deletions autogen/variables.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,33 @@ 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
#################

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 = []
}
Expand Down Expand Up @@ -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"
}
}
12 changes: 9 additions & 3 deletions autogen/versions.tf → autogen/versions.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
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: '0'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
14 changes: 8 additions & 6 deletions examples/compute_instance/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | <pre>object({<br> email = string,<br> scopes = set(string)<br> })</pre> | `null` | no |
| subnetwork | The subnetwork selflink to host the compute instances in | `any` | n/a | yes |

## Outputs

Expand Down
4 changes: 4 additions & 0 deletions examples/compute_instance/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}, ]
}
9 changes: 9 additions & 0 deletions examples/compute_instance/simple/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion examples/compute_instance/simple/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
*/

terraform {
required_version = "~> 0.12.6"
required_version = ">=0.12.6"
}
10 changes: 5 additions & 5 deletions examples/instance_template/additional_disks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | <pre>object({<br> email = string<br> scopes = set(string)<br> })</pre> | `null` | no |
| subnetwork | The name of the subnetwork create this instance in. | `string` | `""` | no |

## Outputs

Expand Down
2 changes: 1 addition & 1 deletion examples/instance_template/additional_disks/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
*/

terraform {
required_version = "~> 0.12.6"
required_version = ">=0.12.6"
}
14 changes: 7 additions & 7 deletions examples/instance_template/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | <pre>object({<br> email = string<br> scopes = set(string)<br> })</pre> | `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

Expand Down
Loading

0 comments on commit 04f7441

Please sign in to comment.