Skip to content

Commit 2aaa628

Browse files
authored
Merge pull request #111 from aws-ia/ephemeral_project-updates
Updates from project type
2 parents ad72497 + f755bcf commit 2aaa628

File tree

8 files changed

+78
-47
lines changed

8 files changed

+78
-47
lines changed

.config/functional_tests/post-entrypoint-helpers.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,14 @@
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

.config/functional_tests/pre-entrypoint-helpers.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,27 @@
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

.copier-answers.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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
44
starting_version: v0.0.0
55
version_file: VERSION
66

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
FROM public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:4.0
22
ENV TERRAFORM_VERSION=1.7.4
3-
ENV GO_VERSION=1.20.2
43
RUN 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

.project_automation/functional_tests/functional_tests.sh

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,27 @@ PROJECT_PATH=${BASE_PATH}/project
66
PROJECT_TYPE_PATH=${BASE_PATH}/projecttype
77

88
echo "Starting Functional Tests"
9-
10-
#********** Terratest execution **********
119
cd ${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

2032
echo "End of Functional Tests"

.project_automation/static_tests/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:4.0
2-
ENV TERRAFORM_VERSION=1.4.2
2+
ENV TERRAFORM_VERSION=1.7.4
33
RUN 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

test/examples_basic_test.go

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

tests/01_mandatory.tftest.hcl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}

0 commit comments

Comments
 (0)