Skip to content

Commit

Permalink
feat!(template): Added option to set stack_type of instance_template (#…
Browse files Browse the repository at this point in the history
…251)

Co-authored-by: Bharath KKB <[email protected]>
Co-authored-by: Andrew Peabody <[email protected]>
  • Loading branch information
3 people authored Nov 30, 2022
1 parent 2b31071 commit bf565b0
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/instance_template/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This is a simple, minimal example of how to use the instance_template module.
| 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#service_account. | <pre>object({<br> email = string<br> scopes = set(string)<br> })</pre> | `null` | 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. If not specified, IPV4\_ONLY will be used. | `string` | `"IPV4_ONLY"` | 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 |
| threads\_per\_core | The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. | `string` | `null` | no |
Expand Down
1 change: 1 addition & 0 deletions examples/instance_template/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module "instance_template" {
source = "../../../modules/instance_template"
project_id = var.project_id
subnetwork = var.subnetwork
stack_type = var.stack_type
service_account = var.service_account
name_prefix = "simple"
tags = var.tags
Expand Down
5 changes: 5 additions & 0 deletions examples/instance_template/simple/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ variable "subnetwork" {
default = ""
}

variable "stack_type" {
description = "The stack type for this network interface to identify whether the IPv6 feature is enabled or not. Values are IPV4_IPV6 or IPV4_ONLY. If not specified, IPV4_ONLY will be used."
default = "IPV4_ONLY"
}

variable "service_account" {
default = null
type = object({
Expand Down
1 change: 1 addition & 0 deletions modules/instance_template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ 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 |
| 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. If not specified, IPV4\_ONLY will be used. | `string` | `"IPV4_ONLY"` | 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 |
Expand Down
1 change: 1 addition & 0 deletions modules/instance_template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ resource "google_compute_instance_template" "tpl" {
subnetwork = var.subnetwork
subnetwork_project = var.subnetwork_project
network_ip = length(var.network_ip) > 0 ? var.network_ip : null
stack_type = var.stack_type
dynamic "access_config" {
for_each = var.access_config
content {
Expand Down
5 changes: 5 additions & 0 deletions modules/instance_template/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ variable "network_ip" {
default = ""
}

variable "stack_type" {
description = "The stack type for this network interface to identify whether the IPv6 feature is enabled or not. Values are IPV4_IPV6 or IPV4_ONLY. If not specified, IPV4_ONLY will be used."
default = "IPV4_ONLY"
}

variable "additional_networks" {
description = "Additional network interface details for GCE, if any."
default = []
Expand Down
2 changes: 1 addition & 1 deletion modules/instance_template/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
terraform {
required_version = ">=0.13.0"
required_providers {
google = ">= 3.71, < 5.0"
google = ">= 3.88, < 5.0"
}
provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-vm:instance_template/v7.9.0"
Expand Down

0 comments on commit bf565b0

Please sign in to comment.