terragrunt

Terraform/OpenTofu 编排封装

补充说明

terragrunt 在 Terraform/OpenTofu 之上提供 DRY 配置、依赖编排和远程状态生成。它适合多环境、多模块的仓库,但会增加一层抽象。

常用示例

terragrunt init
terragrunt plan
terragrunt apply
terragrunt run-all plan
terragrunt run-all apply
terragrunt run-all destroy
terragrunt hclfmt
terragrunt graph-dependencies
terragrunt output

terragrunt.hcl:

include "root" {
  path = find_in_parent_folders()
}

terraform {
  source = "git::https://github.com/example/modules.git//network?ref=v1.2.0"
}

dependency "vpc" {
  config_path = "../vpc"
}

inputs = {
  env        = "prod"
  vpc_id     = dependency.vpc.outputs.vpc_id
}

易错点与排错

相关命令