File tree Expand file tree Collapse file tree 8 files changed +78
-47
lines changed Expand file tree Collapse file tree 8 files changed +78
-47
lines changed Original file line number Diff line number Diff line change 33# # Use this to load any configurations after the functional test
44# # TIPS: avoid modifying the .project_automation/functional_test/entrypoint.sh
55# # migrate any customization you did on entrypoint.sh to this helper script
6- echo " Executing Post-Entrypoint Helpers"
6+ echo " Executing Post-Entrypoint Helpers"
7+
8+ # ********** Project Path *************
9+ PROJECT_PATH=${BASE_PATH} /project
10+ PROJECT_TYPE_PATH=${BASE_PATH} /projecttype
11+ cd ${PROJECT_PATH}
12+
13+ # ********** CLEANUP *************
14+ echo " Cleaning up all temp files and artifacts"
15+ cd ${PROJECT_PATH}
16+ make -s clean
Original file line number Diff line number Diff line change 33# # use this to load any configuration before the functional test
44# # TIPS: avoid modifying the .project_automation/functional_test/entrypoint.sh
55# # migrate any customization you did on entrypoint.sh to this helper script
6- echo " Executing Pre-Entrypoint Helpers"
6+ echo " Executing Pre-Entrypoint Helpers"
7+
8+ # ********** Project Path *************
9+ PROJECT_PATH=${BASE_PATH} /project
10+ PROJECT_TYPE_PATH=${BASE_PATH} /projecttype
11+ cd ${PROJECT_PATH}
12+
13+ # ********** TFC Env Vars *************
14+ export AWS_DEFAULT_REGION=us-east-1
15+ export TFE_TOKEN=` aws secretsmanager get-secret-value --secret-id abp/tfc/token | jq -r " .SecretString" `
16+ export TF_TOKEN_app_terraform_io=` aws secretsmanager get-secret-value --secret-id abp/tfc/token | jq -r " .SecretString" `
17+
18+ # ********** MAKEFILE *************
19+ echo " Build the lambda function packages"
20+ make all
21+
22+ # ********** Get tfvars from SSM *************
23+ echo " Get *.tfvars from SSM parameter"
24+ aws ssm get-parameter \
25+ --name " /abp/tfc/functional/tfc_org/terraform_test.tfvars" \
26+ --with-decryption \
27+ --query " Parameter.Value" \
28+ --output " text" \
29+ --region " us-east-1" >> ./tests/terraform.auto.tfvars
Original file line number Diff line number Diff line change 11# This file is auto-generated, changes will be overwritten
2- _commit : v0.1.3
3- _src_path : /task/8be08035-e60c -11ee-ab69-16475233b5d9 /projecttype
2+ _commit : v0.1.4
3+ _src_path : /task/f281c4e2-f68d -11ee-b0d0-1a8eb7bb45c9 /projecttype
44starting_version : v0.0.0
55version_file : VERSION
66
Original file line number Diff line number Diff line change 11FROM public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:4.0
22ENV TERRAFORM_VERSION=1.7.4
3- ENV GO_VERSION=1.20.2
43RUN cd /tmp && \
54 wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \
6- unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin && chmod 755 /usr/local/bin/terraform
7-
8- RUN cd /tmp && \
9- wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
10- tar -C /usr/local/bin -xzf go${GO_VERSION}.linux-amd64.tar.gz && chmod 755 /usr/local/bin/go
5+ unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin && chmod 755 /usr/local/bin/terraform
Original file line number Diff line number Diff line change @@ -6,15 +6,27 @@ PROJECT_PATH=${BASE_PATH}/project
66PROJECT_TYPE_PATH=${BASE_PATH} /projecttype
77
88echo " Starting Functional Tests"
9-
10- # ********** Terratest execution **********
119cd ${PROJECT_PATH}
12- echo " Running Terratest"
13- cd test
14- rm -f go.mod
15- go mod init github.com/aws-ia/terraform-project-ephemeral
16- go mod tidy
17- go install github.com/gruntwork-io/terratest/modules/terraform
18- go test -timeout 45m
10+
11+ # ********** Terraform Test **********
12+
13+ # Look up the mandatory test file
14+ MANDATORY_TEST_PATH=" ./tests/01_mandatory.tftest.hcl"
15+ if test -f ${MANDATORY_TEST_PATH} ; then
16+ echo " File ${MANDATORY_TEST_PATH} is found, resuming test"
17+ # Run Terraform test
18+ terraform init
19+ terraform test
20+ else
21+ echo " File ${MANDATORY_TEST_PATH} not found. You must include at least one test run in file ${MANDATORY_TEST_PATH} "
22+ (exit 1)
23+ fi
24+
25+ if [ $? -eq 0 ]; then
26+ echo " Terraform Test Successfull"
27+ else
28+ echo " Terraform Test Failed"
29+ exit 1
30+ fi
1931
2032echo " End of Functional Tests"
Original file line number Diff line number Diff line change 11FROM public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:4.0
2- ENV TERRAFORM_VERSION=1.4.2
2+ ENV TERRAFORM_VERSION=1.7.4
33RUN cd /tmp && \
44 wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \
55 unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin && chmod 755 /usr/local/bin/terraform
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ # # NOTE: This is the minimum mandatory test
2+ # run at least one test using the ./examples directory as your module source
3+ # create additional *.tftest.hcl for your own unit / integration tests
4+ # use tests/*.auto.tfvars to add non-default variables
5+
6+ run "mandatory_plan_basic" {
7+ command = plan
8+ module {
9+ source = " ./examples/module_workspace"
10+ }
11+ }
12+
13+ run "mandatory_apply_basic" {
14+ command = apply
15+ module {
16+ source = " ./examples/module_workspace"
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments