Loading...
Loading...
Architect, provision, and troubleshoot infrastructure on Google Cloud using Terraform. This skill ensures best practices like GCS backend usage and least-privilege IAM are followed. Enforces Google's Cloud Foundation Fabric patterns and rigorous validation protocols to ensure secure, idempotent, and scalable deployments across environments. Activate when the user requests infrastructure changes, pipeline design involving Terraform, or debugging Terraform issues. DO NOT use when deploying application code or container images directly via `gcloud` or `kubectl` without Terraform (use `google-cicd-deploy`), designing high-level CI/CD architecture before choosing an IaC tool (use `google-cicd-pipeline-design`), or managing Cloud Deploy releases and rollouts via `clouddeploy.yaml` (use `google-cicd-release-orchestration`).
npx skill4agent add google/skills google-cicd-terraformgcloud>= 1.6.0tflintgcloudgcloud auth logingcloud auth application-default loginGOOGLE_APPLICATION_CREDENTIALSus-central1gcloud config set project <PROJECT_ID>gcloud config set compute/region <REGION>gcloud services enable cloudresourcemanager.googleapis.com serviceusage.googleapis.com iam.googleapis.com storage.googleapis.com cloudbuild.googleapis.com developerconnect.googleapis.com artifactregistry.googleapis.com run.googleapis.com container.googleapis.comterraform planterraform {
backend "gcs" {
# Variables (var.*) are not allowed in backend blocks; set literal values
# or pass via: terraform init -backend-config="bucket=tf-state-<PROJECT_ID>"
bucket = "tf-state-<PROJECT_ID>"
prefix = "terraform/state/<ENVIRONMENT>"
}
}terraform {
required_version = ">= 1.6.0"
required_providers {
google = {
source = "hashicorp/google"
version = ">= 7.20.0"
}
}
}curl -s https://registry.terraform.io/v1/providers/hashicorp/google | jq -r .versionterraform init.terraform.lock.hclterraform validatetflinttflintterraform plan -out=tfplanterraform apply tfplan$ terraform providers schema -jsonresource "google_compute_network" "main" {
name = "${var.prefix}-vpc"
auto_create_subnetworks = false
}google_project_iam_policygoogle_project_iam_membergoogle_project_iam_bindinggoogle_project_iam_membergoogle_project_iam_bindingdeveloper_connect_event_configrepository_event_configrepository_event_configresource "google_cloudbuild_trigger" "main" {
developer_connect_event_config {
git_repository_link = google_developer_connect_git_repository_link.main.id
push {
branch = var.trigger_branch
}
}
}google_developer_connect_connectiongithub_configgithub_enterprise_configgitlab_configgitlab_enterprise_configbitbucket_cloud_configbitbucket_data_center_configgithub_configgithub_app"DEVELOPER_CONNECT""FIREBASE"resource "google_developer_connect_connection" "main" {
location = var.region
connection_id = var.connection_id
project = var.project_id
# Example for GitHub (use gitlab_config / bitbucket_cloud_config for GitLab / Bitbucket):
github_config {
github_app = "DEVELOPER_CONNECT" # CORRECT
authorizer_credential {
oauth_token_secret_version = "" # Populated after manual authorization
}
}
depends_on = [google_project_service.main["developerconnect.googleapis.com"]]
lifecycle {
ignore_changes = [github_config[0].authorizer_credential]
}
}google_developer_connect_git_repository_linkparent_connectiongit_repository_link_idresource "google_developer_connect_git_repository_link" "main" {
location = var.region
parent_connection = google_developer_connect_connection.main.connection_id
git_repository_link_id = "my-repo-link"
clone_uri = var.git_repo_uri
}.
└── terraform/
├── main.tf # Entry point / Resource definitions
├── variables.tf # Typed variables with units and descriptions
├── outputs.tf # Resource ID outputs (no direct input pass-through)
├── versions.tf # Provider version pinning
├── network.tf # (Optional) Grouped networking resources
├── examples/ # Example usage for modules
├── files/ # Static files (startup scripts, etc.)
├── templates/ # .tftpl templates
├── scripts/ # Scripts called by Terraform
└── helpers/ # Scripts NOT called by Terraformgithubgoogle_cloudbuild_triggerdeveloper_connect_event_configdata "google_project"type = stringtype = STRINGterraform test*.tftest.hclterraform plan -destroy -out=tfdestroyterraform apply tfdestroygcloud projects delete <PROJECT_ID>