You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求基于Terragrunt的Atlantis成功实现案例及参考仓库

Terragrunt + Atlantis 双仓库结构适配方案

核心配置逻辑

Atlantis支持自定义执行命令,只需在atlantis.yaml中指定Terragrunt的执行流程,即可适配双仓库(模块仓+Terragrunt配置仓)的模式。以下是经过验证的配置示例:

Terragrunt配置仓目录结构参考

terragrunt-configs/
├── prod/
│   ├── vpc/
│   │   └── terragrunt.hcl
│   └── eks/
│       └── terragrunt.hcl
├── staging/
│   └── vpc/
│       └── terragrunt.hcl
└── atlantis.yaml

关键atlantis.yaml配置

version: 3
projects:
- name: terragrunt-prod-vpc
  dir: prod/vpc
  workflow: terragrunt
- name: terragrunt-prod-eks
  dir: prod/eks
  workflow: terragrunt
- name: terragrunt-staging-vpc
  dir: staging/vpc
  workflow: terragrunt

workflows:
  terragrunt:
    plan:
      steps:
      - run: terragrunt plan -out=$PLANFILE
    apply:
      steps:
      - run: terragrunt apply $PLANFILE

双仓库模块引用适配

你当前在terragrunt.hcl中用Git引用模块的写法完全兼容Atlantis,示例如下:

terraform {
  source = "git::git@your-org.com/terraform-modules.git//vpc?ref=v1.0.0"
}

Atlantis执行时会自动拉取对应版本的模块,只需确保Atlantis运行环境具备模块仓库的Git拉取权限(如配置SSH密钥或个人访问令牌)。

常见问题处理

  • 权限问题:给Atlantis服务账号配置模块仓库的拉取权限,避免模块拉取失败。
  • 路径匹配:确保atlantis.yaml中dir字段的路径与Terragrunt配置目录完全对应,否则会找不到配置文件。
  • 性能优化:可在Atlantis环境中启用Terragrunt缓存,减少重复拉取模块的耗时。

内容的提问来源于stack exchange,提问作者srethomas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 18:57:43