A Terragrunt Template Catalog for production Infrastructure as Code (IaC) on Google Cloud Platform (GCP).
This is a catalog repository, a collection of reusable IaC components.
This IaC production toolkit follows Gruntwork's official patterns by using two template repositories:
- This repository (catalog): Build a collection of reusable modules, units, and stacks
- Live repository: Reference these components in your the infrastructure-live repository to deploy them in a multi-environment ecosystem with production CI/CD
The catalog follows a layered architecture where each layer builds upon the previous one:
Modules (modules/) → Units (units/) → Stacks (stacks/) → Examples (examples/)
- Modules: Reusable Terraform modules that declare GCP resources (VPC, databases, compute instances, etc.)
- Units: Terragrunt wrappers around modules that add configuration and dependencies
- Stacks: Collections of units arranged in dependency graphs for pattern level re-use
- Examples: Simple configuration for testing and development
- Bootstrap: GitHub Actions GCP authentication setup
- CI: Automated configuration validation, testing (
terratest
) and documatentation (terraform-docs
).
First, you'll need to fork this repository and make a few changes:
- Click on
Use this template
to create your own repository - Use your IDE of choice to replace every occurrence of
github.com/ConsciousML/terragrunt-template-catalog-gcp
andgit::[email protected]:ConsciousML/terragrunt-template-catalog-gcp.git
by your GitHub repo URL following the same format - In
examples/
changeregion.hcl
andproject.hcl
to match your GCP settings
Option 1: Use mise (recommended)
First install mise by following their getting started guide, then:
mise install
Option 2: Install Tools Manually
See mise.toml for specific versions.
gcloud auth application-default login
Deploy a stack that activates GCP APIs, sets up a VPC, and spawns a Compute Engine:
cd examples/stacks/vpc_gce
terragrunt stack generate
terragrunt stack run apply --backend-bootstrap --non-interactive
- Go into the GCP console and check that your resources have been created
- Then cleanup by destroying the infrastructure:
cd examples/stacks/vpc_gce
terragrunt stack generate
terragrunt stack run destroy --non-interactive
Caution: This workflow is for development and testing. Reference your catalog components in the infrastructure-live repository for multi-environment IaC, and production CI/CD.
- Create a feature branch
- Write/modify modules, units, and stacks
- Test locally using examples
- Create pull request
- Merge when CI passes
See the development guide for a detailed workflow with a step-by-step example on how to modify this template.
After creating your repository from this template, run the bootstrap process once to configure GitHub Actions authentication with GCP.
The CI provides automated checks and testing:
- Create a branch and make changes
- Open a pull request to trigger code quality checks
- Add the
run-terratest
label for full infrastructure testing - Merge when all checks pass
Read more in our CI workflow guide.
The run-terratest
label triggers automated infrastructure tests that deploy real GCP resources, validate functionality, and clean up automatically.
See the testing guide for writing custom tests.
pre-commit install
This runs the same checks as CI locally, catching issues before you push.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.