diff --git a/README.md b/README.md index 15b75ad..c96a93a 100644 --- a/README.md +++ b/README.md @@ -69,16 +69,18 @@ export ARM_SUBSCRIPTION_ID="" * The Google Cloud IAM roles listed below are required by the provisioning account to create the GCP pre-requisite resources. -| IAM Role | -| ------------------------- | -| Compute Network Admin | -| Compute Security Admin | -| Role Administrator | -| Security Admin | -| Service Account Admin | -| Service Account Key Admin | -| Storage Admin | -| Viewer | +| IAM Role | +| ------------------------- | +| Compute Network Admin | +| Compute Security Admin | +| Role Administrator | +| Security Admin | +| Service Account Admin | +| Service Account Key Admin | +| Storage Admin | +| Viewer | + +* The Google project Id can be specified via the `gcp_project` input variable, the `GOOGLE_PROJECT` environment variable or the default project set via the Cloud SDK. This is described in the [Google Provider Default Values Configuration](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#provider-default-values-configuration) documentation. ### Input file configuration diff --git a/gcp/main.tf b/gcp/main.tf index 5dbf82f..7373ec6 100755 --- a/gcp/main.tf +++ b/gcp/main.tf @@ -66,7 +66,7 @@ module "cdp_deploy" { env_prefix = var.env_prefix infra_type = "gcp" - gcp_project_id = var.gcp_project + gcp_project_id = data.google_project.project.project_id region = var.gcp_region public_key_text = local.public_key_text deployment_template = var.deployment_template @@ -105,6 +105,9 @@ module "cdp_deploy" { ] } +# Use the Google Cloud Provider to retrieve GCP project details +data "google_project" "project" {} + # ------- Create SSH Keypair if input public_key_text variable is not specified locals { # flag to determine if keypair should be created diff --git a/gcp/variables.tf b/gcp/variables.tf index 0432207..61e5a5e 100755 --- a/gcp/variables.tf +++ b/gcp/variables.tf @@ -20,7 +20,9 @@ variable "env_prefix" { variable "gcp_project" { type = string - description = "Region which Cloud resources will be created" + description = "Region which Cloud resources will be created. Can also be set via gcloud project default or environment variable." + + default = null } variable "gcp_region" {