Generate backend file for GCS with terragrunt
Why
When using terragrunt, we want to generate files to keep deployments DRY. We can use a built-in function to create the backend file
How
# terragrunt.hcl
remote_state {
backend = "gcs"
generate = {
path = "backend.tf"
if_exists = "overwrite_terragrunt"
}
config = {
project = "<>"
location = "eu"
bucket = "<>"
prefix = "${path_relative_to_include()}"
skip_bucket_creation = true
}
}
What it generates
# backend.tf
# Generated by Terragrunt. Sig: nIlQXj57tbuaRZEa
terraform {
backend "gcs" {
bucket = "<>"
prefix = "sandbox"
}
}
Want to make this site better? Open a PR or help fund hosting costs