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

Terragrunt的--terragrunt-source-map未生效,如何排查问题?

Terragrunt --terragrunt-source-map 不生效问题解决

核心问题:源地址匹配不完整

你当前使用的--terragrunt-source-map只匹配了基础仓库地址,但输出里显示Terragrunt实际拉取的模块地址带了?ref=develop参数,source-map的键必须和Terragrunt加载的完整模块地址完全一致,包括分支/标签参数。

具体修正步骤

  1. 修正source-map的匹配地址
    将命令中的源地址替换为包含?ref=develop的完整路径,同时确保本地路径对应远程模块的实际子目录(输出显示远程模块在仓库的modules/data_org下):

    terragrunt --terragrunt-source-map "git::ssh://git@git.lony.xy/ops/terraform_modules.git?ref=develop=/Users/lony/Desktop/source_map/modules/data_org" --terragrunt-source-update apply
    

    如果你本地的/Users/lony/Desktop/source_map就是直接对应远程的modules/data_org内容,就把本地路径设为/Users/lony/Desktop/source_map。

  2. 清理缓存确保生效
    若修正后仍无变化,手动清理Terragrunt和Terraform的缓存目录:

    • 删除当前目录下的.terragrunt-cache文件夹
    • 删除.terraform文件夹和.terraform.lock.hcl文件
      再重新执行命令。
  3. 检查Terragrunt配置优先级
    确认你的terragrunt.hcl中source字段的定义是否和命令行匹配,比如配置里如果写了:

    source = "git::ssh://git@git.lony.xy/ops/terraform_modules.git//modules/data_org?ref=develop"
    

    那source-map的键需要完全匹配这个完整字符串:

    terragrunt --terragrunt-source-map "git::ssh://git@git.lony.xy/ops/terraform_modules.git//modules/data_org?ref=develop=/Users/lony/Desktop/source_map" --terragrunt-source-update apply
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 06:03:23