Skip to content

Getting Started#

This guide will help you get up and running with infrastructure as code on Google Cloud Platform using Terragrunt and OpenTofu/Terraform.

Prerequisites#

Before you begin, ensure you have the following installed and configured:

  • OpenTofu or Terraform (version 1.0+)
# For OpenTofu
tofu --version

# For Terraform
terraform --version
  • Terragrunt (version 0.50+)
terragrunt --version
  • Google Cloud SDK (gcloud)

Refer to the Google Cloud SDK documentation for installation instructions.

gcloud --version
  • Google Cloud Account with appropriate permissions
  • Organization Owner or Editor role
  • Billing account linked to your project

Initial Setup#

1. Authenticate with Google Cloud#

# Login to your Google Cloud account
gcloud auth login --update-adc

2. Verify Your Setup#

# Check your current configuration
gcloud config list

# Verify OpenTofu/Terraform can access Google Cloud
tofu version  # or terraform version

# Verify Terragrunt installation
terragrunt --version

Quick Start with Terragrunt#

1. Understanding Terragrunt#

Terragrunt is a thin wrapper for OpenTofu/Terraform that provides extra tools for working with multiple modules and managing remote state. For a comprehensive introduction, see the Terragrunt Quick Start Guide.

2. Clone or Download Configuration#

Choose one of our pre-built Terragrunt modules or create your own configuration files with terragrunt.hcl.

3. Working with a single module#

# Review what Terragrunt will create
terragrunt plan

4. Apply Your Configuration#

# Deploy your infrastructure
terragrunt apply

5. Working with Multiple Modules#

# Plan all modules
terragrunt run-all plan

# Apply all modules in subdirectories
terragrunt run-all apply

Terragrunt vs OpenTofu/Terraform#

This library leverages Terragrunt's capabilities to:

  • Manage remote state automatically across multiple environments
  • Handle dependencies between modules
  • Reduce code duplication with shared configurations
  • Simplify multi-environment deployments

While you can use plain OpenTofu/Terraform, Terragrunt provides additional benefits for managing complex infrastructure at scale.

Next Steps#