如何从Terratest Go脚本调用Terragrunt HCL文件?

问题描述

我有一个terragrunt脚本,该脚本在运行terragrunt Apply-all命令行后运行良好,但同样,我无法执行/调用Go表格。使用 TgApplyAll >功能

下面是我的Go脚本 可用的terragrunt脚本保存在D:\ vertica-terragrunt-US-286094-Modules \ with-infra位置,并且可以通过手动 terragrunt apply-all 命令正常运行,但是从Go脚本获取错误

enter image description here

出现以下错误

''' github.com/gruntwork-io/terratest/modules/terraform.TgInvalidBinary.Error(...) c:/go/pkg/mod/github.com/gruntwork-io/terratest@v0.30.15/modules/terraform/errors.go:12

详细错误 func(err TgInvalidBinary)Error()字符串{ return fmt.Sprintf(“ terragrunt必须设置为terraformBinary才能使用此功能。[terraformBinary:%s]”,err) } '''

我使用了与我从terratest Go脚本中调用terraform代码调用terragrunt代码相同的代码,但是它不起作用

有人可以帮助我/将我定向到位置,例如如何从terratest Go脚本中调用有效的terragrunt代码吗?

解决方法

你好,您需要在terraform选项中将TerraformBinary设置为terragrunt:

terraformOptions := &terraform.Options{

    TerraformDir: "D:/vertica-terragrunt-US-286094-Modules/with-infra",TerraformBinary : "terragrunt",}

因为默认二进制是terraform,并且在调用terragrunt函数并将TerraformBinary设置为terragrunt以外的值时会发生TgInvalidBinary。

这是裁判

https://godoc.org/github.com/gruntwork-io/terratest/modules/terraform#TgInvalidBinary

https://github.com/gruntwork-io/terratest/blob/master/modules/terraform/cmd.go

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...