我正在为 terraform 模块编写测试用例。我有一个假设角色,我想将它传递给我的 go 测试。我不知道如何通过它。我将它定义为一个常量,然后我应该如何传递它以便它在 terraform init 和 terraform apply、destroy 期间被唤起。
package test
import (
"testing"
"github.com/gruntwork-io/terratest/modules/aws"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// An example of how to test the Terraform module in examples/terraform-aws-network-example using Terratest.
func TestTerraformAwsNetworkExample(t *testing.T) {
t.Parallel()
const authAssumeRoleEnvVar = "TERRATEST_IAM_ROLE"
// Give the VPC and the subnets correct CIDRs
vpcCidr := "1x.x.x.x/20"
Env := "staging"
privateSubnetCidr := []string{"1x.x.x.x/30"}
publicSubnetCidr := []string{"1x.x.x.x/30"}
Tag := map[string]string{"owner":"xxx"}
awsRegion := "us-east-1"
terraformOptions := &terraform.Options{
// The path to where our Terraform code is located
TerraformDir: "..",
// Variables to pass to our Terraform code using -var options
Vars: map[string]interface{}{
"vpc_cidr": vpcCidr,
"env": Env,
"private_subnet_cidrs": privateSubnetCidr,
"public_subnet_cidrs": publicSubnetCidr,
"tags" : Tag,
},
EnvVars: map[string]string{
"AWS_DEFAULT_REGION": awsRegion,
},
}
}
慕尼黑8549860
SMILET
相关分类