Skip to content

Commit d35ac4f

Browse files
authored
Merge pull request #51 from wellsiau-aws/ws-ssm-param
Feat: parameterized test
2 parents cf3f40b + d4e903f commit d35ac4f

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

.project_automation/functional_tests/entrypoint.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,26 @@ export TF_TOKEN_app_terraform_io=`aws secretsmanager get-secret-value --secret-i
1818
echo "Build the lambda function packages"
1919
make all
2020

21+
#********** Get tfvars from SSM *************
22+
echo "Get *.tfvars from SSM parameter"
23+
aws ssm get-parameter \
24+
--name "/abp/tfc/functional/tfvars" \
25+
--with-decryption \
26+
--query "Parameter.Value" \
27+
--output "text" \
28+
--region "us-east-1" >> functional_test.tfvars
29+
2130
#********** Checkov Analysis *************
2231
echo "Running Checkov Analysis on root module"
2332
checkov --directory . --skip-path examples --framework terraform
2433

2534
echo "Running Checkov Analysis on terraform plan"
2635
terraform init
27-
terraform plan -out tf.plan -var-file .project_automation/functional_tests/functional_test.tfvars
36+
terraform plan -out tf.plan -var-file functional_test.tfvars
2837
terraform show -json tf.plan > tf.json
2938
checkov
3039

31-
#********** Terratest execution **********
40+
# #********** Terratest execution **********
3241
echo "Running Terratest"
3342
export GOPROXY=https://goproxy.io,direct
3443
cd test

.project_automation/functional_tests/functional_test.tfvars

Lines changed: 0 additions & 2 deletions
This file was deleted.

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ clean:
1717
rm -f ./test/go.mod
1818
rm -f ./test/go.sum
1919
rm -f tf.json
20-
rm -f tf.plan
20+
rm -f tf.plan
21+
rm -f *.tfvars

test/examples_basic_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@ package test
33
import (
44
"testing"
55

6+
"github.com/gruntwork-io/terratest/modules/aws"
67
"github.com/gruntwork-io/terratest/modules/terraform"
78
)
89

910
func TestExamplesBasic(t *testing.T) {
1011

12+
awsRegion := "us-east-1"
13+
ssmTfcOrg := aws.GetParameter(t, awsRegion, "/abp/tfc/functional/tfc_org")
14+
ssmWorkspacePrefix := aws.GetParameter(t, awsRegion, "/abp/tfc/functional/workspace_prefix")
15+
1116
terraformOptions := &terraform.Options{
1217
Lock: true, // Required for TFC with local execution
1318
TerraformDir: "../examples/module_workspace",
1419
Vars: map[string]interface{}{
15-
"tfc_org": "wellsiau-org",
16-
"workspace_prefix": "ia2",
20+
"tfc_org": ssmTfcOrg,
21+
"workspace_prefix": ssmWorkspacePrefix,
1722
},
1823
}
1924

0 commit comments

Comments
 (0)