Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for GCP project as env vars #43

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,18 @@ export ARM_SUBSCRIPTION_ID="<sp_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

Expand Down
5 changes: 4 additions & 1 deletion gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
Loading