在 Windows 10 中从 Visual Studio 代码执行“terragrunt plan”会出现以下错误:
运行命令:terraform init -backend-config=region=eu-west-2 -backend-config=bucket=bucket-name" -backend-config=dynamodb_table=lock-table -backend-config=encrypt=true -backend- config=key=ec2/terraform.tfstate
正在初始化后端...
后端“s3”配置成功! Terraform 会自动 除非后端配置发生变化,否则使用此后端。
正在初始化提供商插件...
错误:无法安装提供程序
安装 hashicorp/aws v3.36.0 时出错:mkdir .terraform/plugins/registry.terraform.io/hashicorp/aws/3.36.0/windows_amd64: 文件名或扩展名太长。
[terragrunt] 2021/05/19 15:39:20 遇到多个错误: 退出状态 1
感谢 Rubens 建议使用
TERRAGRUNT_DOWNLOAD
环境变量。我可以解决这个问题。
以下是 terragrunt 中的完整步骤:
set TERRAGRUNT_DOWNLOAD=C:\\.terragrunt-cache
terragrunt init
然后将
C:\\.terragrunt-cache
内容复制或移动到我项目中的.terragrunt-cache
(最好先清理文件夹)
从 cmd 取消设置 TERRAGRUNT_DOWNLOAD 并调用 apply
set TERRAGRUNT_DOWNLOAD=
terragrunt apply
今天遇到了这个问题,我通过创建一个
TERRAGRUNT_DOWNLOAD
环境变量解决了。
我将值设置为
TERRAGRUNT_DOWNLOAD=C:\.terragrunt-cache
。
从这个问题得到了这个解决方案 https://github.com/gruntwork-io/terragrunt/issues/581#issuecomment-460051767
如果
Terragruntis
正在使用Git for Windows
,你可以用解决它
以管理员身份在命令提示符中运行
git config --system core.longpaths true
我在 terraform init 上遇到了类似的问题。我安装了最新版本的 terraform 并且它得到了解决。