Skip to content

Commit d959936

Browse files
ryboeg-awmalik
andauthored
feat: add var.resource_policies to instance_template (#317)
Co-authored-by: Awais Malik <[email protected]>
1 parent 76e9c19 commit d959936

File tree

10 files changed

+37
-14
lines changed

10 files changed

+37
-14
lines changed

modules/compute_disk_snapshot/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
repo: https://github.com/terraform-google-modules/terraform-google-vm
2626
sourceType: git
2727
dir: /modules/compute_disk_snapshot
28-
version: 9.0.0
28+
version: 10.0.0
2929
actuationTool:
3030
flavor: Terraform
3131
version: ">=0.13.0"

modules/compute_instance/metadata.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
repo: https://github.com/terraform-google-modules/terraform-google-vm
2626
sourceType: git
2727
dir: /modules/compute_instance
28-
version: 9.0.0
28+
version: 10.0.0
2929
actuationTool:
3030
flavor: Terraform
3131
version: ">=0.13.0"
@@ -134,6 +134,10 @@ spec:
134134
description: Region where the instances should be created.
135135
varType: string
136136
defaultValue: null
137+
- name: resource_manager_tags
138+
description: (Optional) A tag is a key-value pair that can be attached to a Google Cloud resource. You can use tags to conditionally allow or deny policies based on whether a resource has a specific tag. This value is not returned by the API. In Terraform, this value cannot be updated and changing it will recreate the resource.
139+
varType: map(string)
140+
defaultValue: null
137141
- name: resource_policies
138142
description: (Optional) A list of short names or self_links of resource policies to attach to the instance. Modifying this list will cause the instance to recreate. Currently a max of 1 resource policy is supported.
139143
varType: list(string)

modules/instance_template/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example.
4141
| preemptible | Allow the instance to be preempted | `bool` | `false` | no |
4242
| project\_id | The GCP project ID | `string` | `null` | no |
4343
| region | Region where the instance template should be created. | `string` | `null` | no |
44+
| resource\_policies | A list of self\_links of resource policies to attach to the instance. Modifying this list will cause the instance to recreate. Currently a max of 1 resource policy is supported. | `list(string)` | `[]` | no |
4445
| 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> | n/a | yes |
4546
| shielded\_instance\_config | Not used unless enable\_shielded\_vm is true. Shielded VM configuration for the instance. | <pre>object({<br> enable_secure_boot = bool<br> enable_vtpm = bool<br> enable_integrity_monitoring = bool<br> })</pre> | <pre>{<br> "enable_integrity_monitoring": true,<br> "enable_secure_boot": true,<br> "enable_vtpm": true<br>}</pre> | no |
4647
| source\_image | Source disk image. If neither source\_image nor source\_image\_family is specified, defaults to the latest public CentOS image. | `string` | `""` | no |

modules/instance_template/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ resource "google_compute_instance_template" "tpl" {
7373
metadata_startup_script = var.startup_script
7474
region = var.region
7575
min_cpu_platform = var.min_cpu_platform
76+
resource_policies = var.resource_policies
7677
dynamic "disk" {
7778
for_each = local.all_disks
7879
content {

modules/instance_template/metadata.yaml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
repo: https://github.com/terraform-google-modules/terraform-google-vm
2626
sourceType: git
2727
dir: /modules/instance_template
28-
version: 9.0.0
28+
version: 10.0.0
2929
actuationTool:
3030
flavor: Terraform
3131
version: ">=0.13.0"
@@ -86,13 +86,14 @@ spec:
8686
description: List of maps of additional disks. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#disk_name
8787
varType: |-
8888
list(object({
89-
disk_name = string
90-
device_name = string
91-
auto_delete = bool
92-
boot = bool
93-
disk_size_gb = number
94-
disk_type = string
95-
disk_labels = map(string)
89+
disk_name = string
90+
device_name = string
91+
auto_delete = bool
92+
boot = bool
93+
disk_size_gb = number
94+
disk_type = string
95+
disk_labels = map(string)
96+
source_snapshot = optional(string)
9697
}))
9798
defaultValue: []
9899
- name: additional_networks
@@ -233,6 +234,10 @@ spec:
233234
description: Region where the instance template should be created.
234235
varType: string
235236
defaultValue: null
237+
- name: resource_policies
238+
description: A list of self_links of resource policies to attach to the instance. Modifying this list will cause the instance to recreate. Currently a max of 1 resource policy is supported.
239+
varType: list(string)
240+
defaultValue: []
236241
- name: service_account
237242
description: Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account.
238243
varType: |-
@@ -270,6 +275,10 @@ spec:
270275
description: Provision a SPOT instance
271276
varType: bool
272277
defaultValue: false
278+
- name: spot_instance_termination_action
279+
description: Action to take when Compute Engine preempts a Spot VM.
280+
varType: string
281+
defaultValue: STOP
273282
- name: stack_type
274283
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`. Default behavior is equivalent to IPV4_ONLY.
275284
varType: string
@@ -303,6 +312,8 @@ spec:
303312
description: Name of instance template
304313
- name: self_link
305314
description: Self-link of instance template
315+
- name: self_link_unique
316+
description: Unique self-link of instance template (recommended output to use instead of self_link)
306317
- name: tags
307318
description: Tags that will be associated with instance(s)
308319
requirements:

modules/instance_template/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ variable "threads_per_core" {
109109
default = null
110110
}
111111

112+
variable "resource_policies" {
113+
type = list(string)
114+
description = "A list of self_links of resource policies to attach to the instance. Modifying this list will cause the instance to recreate. Currently a max of 1 resource policy is supported."
115+
default = []
116+
}
117+
112118
#######
113119
# disk
114120
#######

modules/mig/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
repo: https://github.com/terraform-google-modules/terraform-google-vm
2626
sourceType: git
2727
dir: /modules/mig
28-
version: 9.0.0
28+
version: 10.0.0
2929
actuationTool:
3030
flavor: Terraform
3131
version: ">=0.13.0"

modules/mig_with_percent/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
repo: https://github.com/terraform-google-modules/terraform-google-vm
2626
sourceType: git
2727
dir: /modules/mig_with_percent
28-
version: 9.0.0
28+
version: 10.0.0
2929
actuationTool:
3030
flavor: Terraform
3131
version: ">=0.13.0"

modules/preemptible_and_regular_instance_templates/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
repo: https://github.com/terraform-google-modules/terraform-google-vm
2626
sourceType: git
2727
dir: /modules/preemptible_and_regular_instance_templates
28-
version: 9.0.0
28+
version: 10.0.0
2929
actuationTool:
3030
flavor: Terraform
3131
version: ">=0.13.0"

modules/umig/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
repo: https://github.com/terraform-google-modules/terraform-google-vm
2626
sourceType: git
2727
dir: /modules/umig
28-
version: 9.0.0
28+
version: 10.0.0
2929
actuationTool:
3030
flavor: Terraform
3131
version: ">=0.13.0"

0 commit comments

Comments
 (0)