Skip to content

Commit

Permalink
feat: add var.resource_policies to instance_template (#317)
Browse files Browse the repository at this point in the history
Co-authored-by: Awais Malik <[email protected]>
  • Loading branch information
ryboe and g-awmalik authored Sep 29, 2023
1 parent 76e9c19 commit d959936
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 14 deletions.
2 changes: 1 addition & 1 deletion modules/compute_disk_snapshot/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
repo: https://github.com/terraform-google-modules/terraform-google-vm
sourceType: git
dir: /modules/compute_disk_snapshot
version: 9.0.0
version: 10.0.0
actuationTool:
flavor: Terraform
version: ">=0.13.0"
Expand Down
6 changes: 5 additions & 1 deletion modules/compute_instance/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
repo: https://github.com/terraform-google-modules/terraform-google-vm
sourceType: git
dir: /modules/compute_instance
version: 9.0.0
version: 10.0.0
actuationTool:
flavor: Terraform
version: ">=0.13.0"
Expand Down Expand Up @@ -134,6 +134,10 @@ spec:
description: Region where the instances should be created.
varType: string
defaultValue: null
- name: resource_manager_tags
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.
varType: map(string)
defaultValue: null
- name: resource_policies
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.
varType: list(string)
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 @@ -41,6 +41,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example.
| preemptible | Allow the instance to be preempted | `bool` | `false` | no |
| project\_id | The GCP project ID | `string` | `null` | no |
| region | Region where the instance template should be created. | `string` | `null` | no |
| 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 |
| 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 |
| 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 |
| source\_image | Source disk image. If neither source\_image nor source\_image\_family is specified, defaults to the latest public CentOS image. | `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 @@ -73,6 +73,7 @@ resource "google_compute_instance_template" "tpl" {
metadata_startup_script = var.startup_script
region = var.region
min_cpu_platform = var.min_cpu_platform
resource_policies = var.resource_policies
dynamic "disk" {
for_each = local.all_disks
content {
Expand Down
27 changes: 19 additions & 8 deletions modules/instance_template/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
repo: https://github.com/terraform-google-modules/terraform-google-vm
sourceType: git
dir: /modules/instance_template
version: 9.0.0
version: 10.0.0
actuationTool:
flavor: Terraform
version: ">=0.13.0"
Expand Down Expand Up @@ -86,13 +86,14 @@ spec:
description: List of maps of additional disks. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#disk_name
varType: |-
list(object({
disk_name = string
device_name = string
auto_delete = bool
boot = bool
disk_size_gb = number
disk_type = string
disk_labels = map(string)
disk_name = string
device_name = string
auto_delete = bool
boot = bool
disk_size_gb = number
disk_type = string
disk_labels = map(string)
source_snapshot = optional(string)
}))
defaultValue: []
- name: additional_networks
Expand Down Expand Up @@ -233,6 +234,10 @@ spec:
description: Region where the instance template should be created.
varType: string
defaultValue: null
- name: resource_policies
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.
varType: list(string)
defaultValue: []
- name: service_account
description: Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account.
varType: |-
Expand Down Expand Up @@ -270,6 +275,10 @@ spec:
description: Provision a SPOT instance
varType: bool
defaultValue: false
- name: spot_instance_termination_action
description: Action to take when Compute Engine preempts a Spot VM.
varType: string
defaultValue: STOP
- name: 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`. Default behavior is equivalent to IPV4_ONLY.
varType: string
Expand Down Expand Up @@ -303,6 +312,8 @@ spec:
description: Name of instance template
- name: self_link
description: Self-link of instance template
- name: self_link_unique
description: Unique self-link of instance template (recommended output to use instead of self_link)
- name: tags
description: Tags that will be associated with instance(s)
requirements:
Expand Down
6 changes: 6 additions & 0 deletions modules/instance_template/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ variable "threads_per_core" {
default = null
}

variable "resource_policies" {
type = list(string)
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."
default = []
}

#######
# disk
#######
Expand Down
2 changes: 1 addition & 1 deletion modules/mig/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
repo: https://github.com/terraform-google-modules/terraform-google-vm
sourceType: git
dir: /modules/mig
version: 9.0.0
version: 10.0.0
actuationTool:
flavor: Terraform
version: ">=0.13.0"
Expand Down
2 changes: 1 addition & 1 deletion modules/mig_with_percent/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
repo: https://github.com/terraform-google-modules/terraform-google-vm
sourceType: git
dir: /modules/mig_with_percent
version: 9.0.0
version: 10.0.0
actuationTool:
flavor: Terraform
version: ">=0.13.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
repo: https://github.com/terraform-google-modules/terraform-google-vm
sourceType: git
dir: /modules/preemptible_and_regular_instance_templates
version: 9.0.0
version: 10.0.0
actuationTool:
flavor: Terraform
version: ">=0.13.0"
Expand Down
2 changes: 1 addition & 1 deletion modules/umig/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
repo: https://github.com/terraform-google-modules/terraform-google-vm
sourceType: git
dir: /modules/umig
version: 9.0.0
version: 10.0.0
actuationTool:
flavor: Terraform
version: ">=0.13.0"
Expand Down

0 comments on commit d959936

Please sign in to comment.