我正在尝试理解如何覆盖Terraform后端(在我的例子中是远程状态),并在设置Terratest Terraform测试时使用本地状态。
我正在使用Terratest测试一些Terraform代码,我们在s3中远程管理状态。在Terratest期间,我想使用本地状态,但在"terraform init“状态下,它无法找到覆盖它的方法。
任何帮助我们都将不胜感激。
发布于 2019-05-21 22:52:57
Terraform允许使用command line options to control backend configuration。由于您使用的是Terratest,因此必须将这些backend options传递给Init。
package terraform
import (
"fmt"
"testing"
)
// InitE calls terraform init and return stdout/stderr.
func InitE(t *testing.T, options *Options) (string, error) {
args := []string{"init", fmt.Sprintf("-upgrade=%t", options.Upgrade)}
args = append(args, FormatTerraformBackendConfigAsArgs(options.BackendConfig)...)
return RunTerraformCommandE(t, options, args...)
}https://stackoverflow.com/questions/56238612
复制相似问题