The standard terraform boilerplate for Google Compute Engine (GCE/GCP) is:
provider "google" {}
How can I get my default project
and region
with that? I need something analogous to aws_region
in AWS (like in this question).
In some cases these are specified externally in the environment variables:
export GOOGLE_PROJECT=myproject
export GOOGLE_REGION=europe-west2
terraform apply
Less often they are explicitly visible in hcl code:
provider "google" {
project = "myproject"
region = "europe-west2"
}
How to proceed when neither is the case?
Basic
Use the google_client_config data source:
Mutliple providers
This can be used even with multiple providers:
Output: