Skip to content

Commit

Permalink
Add Terraform Cloud Run example for multiple environment variables
Browse files Browse the repository at this point in the history
`env` has to be declared multiple times in this format to declare
multiple variables.
  • Loading branch information
glasnt committed Dec 19, 2019
1 parent f38d8f1 commit ab497a2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions products/cloudrun/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ overrides: !ruby/object:Overrides::ResourceOverrides
cloud_run_service_name: "tftest-cloudrun"
test_env_vars:
project: :PROJECT_NAME
- !ruby/object:Provider::Terraform::Examples
name: "cloud_run_service_multiple_environment_variables"
primary_resource_id: "default"
primary_resource_name: "fmt.Sprintf(\"tftest-cloudrun%s\", context[\"random_suffix\"])"
vars:
cloud_run_service_name: "tftest-cloudrun"
test_env_vars:
project: :PROJECT_NAME
custom_code: !ruby/object:Provider::Terraform::CustomCode
encoder: 'templates/terraform/encoders/cloud_run_service.go.erb'
decoder: 'templates/terraform/decoders/cloud_run.go.erb'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resource "google_cloud_run_service" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['cloud_run_service_name'] %>"
location = "us-central1"

template {
spec {
containers {
image = "gcr.io/cloudrun/hello"
}
env {
name = "SOURCE"
value = "remote"
}
env {
name = "TARGET"
value = "home"
}
}
}

traffic {
percent = 100
latest_revision = true
}
}

0 comments on commit ab497a2

Please sign in to comment.