Menu

📰
0

Terragrunt remote_state and generate blocks

DEV Community: terraform·Bartłomiej Danek·about 1 month ago
#rH9yssdp
#dev#class#code#highlight#terragrunt#photo
Reading 0:00
15s threshold

Terragrunt remote_state and generate blocks remote_state Defines the backend once in root.hcl - Terragrunt auto-generates the backend config for every unit that includes it. # root.hcl remote_state { backend = "s3" config = { bucket = "my-tf-state" key = "${path_relative_to_include()}/terraform.tfstate" region = "eu-west-1" encrypt = true dynamodb_table = "terraform-locks" } generate = { path = "backend.tf" if_exists = "overwrite_terragrunt" } } path_relative_to_include() resolves to the path of the calling terragrunt.hcl relative to root.hcl - e.g. environments/prod/vpc - giving each unit a unique state key automatically. generate block Writes any file before running Terraform - typically used for provider.tf and backend.tf so they don't need to be duplicated in every module.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More