Skip to content

Commit

Permalink
support metadata field in compute instance template (#860)
Browse files Browse the repository at this point in the history
* support metadata field in compute instance template

Fixes #859

* use hcl
  • Loading branch information
xingao267 authored Mar 30, 2021
1 parent eb23d1e commit 212ca1b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/tfengine/schemas/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ Labels to set on the instance template.

Type: object

### compute_instance_templates.metadata

Metadata to set on the instance template.

Type: object

### compute_instance_templates.name_prefix

Name prefix of the instance template.
Expand Down
3 changes: 3 additions & 0 deletions examples/tfengine/generated/team/project_apps/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ module "instance_template" {
env = "prod"
type = "no-phi"
}
metadata = {
enable-oslogin = "TRUE"
}
depends_on = [
module.project
]
Expand Down
3 changes: 3 additions & 0 deletions examples/tfengine/modules/team.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ template "project_apps" {
labels = {
type = "no-phi"
}
metadata = {
enable-oslogin = "TRUE"
}
tags = [
"service",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ EOF
{{end -}}
}
{{end -}}


{{if has . "metadata" -}}
metadata = {
{{hcl .metadata}}
}
{{end -}}

depends_on =[
module.project
]
Expand Down
4 changes: 4 additions & 0 deletions templates/tfengine/recipes/resources.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ schema = {
".+" = { type = "string" }
}
}
metadata = {
description = "Metadata to set on the instance template."
type = "object"
}
instances = {
description = "[Module](https://github.com/terraform-google-modules/terraform-google-vm/tree/master/modules/compute_instance)"
type = "array"
Expand Down

0 comments on commit 212ca1b

Please sign in to comment.