Thanks to visit codestin.com
Credit goes to github.com

Skip to content

OctavioM/gcp-terraform

Repository files navigation

**Terraform GCP Setup **

⚙️ Prerequisites

Install the following:

Terraform
Google Cloud SDK (gcloud)
✅ A Google Cloud Project with billing enabled

Authenticate with Google Cloud

Run the following command to authenticate with a dedicated service account:

cloud auth activate-service-account [ACCOUNT] --key-file=KEY_FILE

🚀 How to Use

1️⃣ Initialize Terraform

Run this once to download provider plugins and set up the working directory:

terraform init

2️⃣ Set Your Variables

Edit the terraform.tfvars file (do not commit this file) and set your GCP project details:

project_id = "your-gcp-project-id"
region     = "europe-west1"

3️⃣ Plan the Deployment

Preview the changes Terraform will make:

terraform plan

4️⃣ Apply the Changes

Deploy the configuration to GCP:

terraform apply

5️⃣ Check Outputs

After deployment, Terraform will output the service account email:

terraform output

🔄 Reusing the Service Account Module

The service-account module can be reused in other projects by calling it like this:

module "new_service_account" {
  source               = "./modules/service-account"
  project_id           = var.project_id
  service_account_name = "custom-sa"
  display_name         = "Custom Service Account"
  roles               = ["roles/editor", "roles/bigquery.admin"]
}

📌 Cleanup

To destroy the resources and remove everything:

terraform destroy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages