Skip to content

Commit a7117f3

Browse files
authored
Initial version 0.0.1 (#29)
Terraform Cloud Agent on Amazon ECS cluster * Feature : bring your own ECS cluster * Feature : single execution mode * Feature : Fargate Spot
1 parent 24e3539 commit a7117f3

31 files changed

+547
-100
lines changed

.config/.checkov.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
download-external-modules: False
22
evaluate-variables: true
3-
file:
4-
- 'tf.json'
3+
directory:
4+
- ./
55
framework:
6-
- terraform_plan
6+
- terraform
77
skip-check:
88
- CKV2_GCP*
99
- CKV_AZURE*
1010
- CKV2_AZURE*
11-
repo-root-for-plan-enrichment:
12-
- '.'
1311
summary-position: bottom
1412
output: 'cli'
1513
compact: True
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
## NOTE: this script runs at the end of functional test
3-
## Use this to load any configurations after the functional test
3+
## 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
66
echo "Executing Post-Entrypoint Helpers"
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
#!/bin/bash
22
## NOTE: this script runs at the start of functional test
3-
## use this to load any configuration before the functional test
3+
## 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+
#********** TFC Env Vars *************
9+
echo "Load env vars"
10+
export AWS_DEFAULT_REGION=us-west-2
11+
export TFE_TOKEN=`aws secretsmanager get-secret-value --secret-id abp/hcp/token | jq -r ".SecretString"`
12+
13+
#********** Get tfvars from SSM *************
14+
echo "Get *.tfvars from SSM parameter"
15+
aws ssm get-parameter \
16+
--name "/abp/hcp/functional/terraform_test.tfvars" \
17+
--with-decryption \
18+
--query "Parameter.Value" \
19+
--output "text" \
20+
--region "us-west-2" > ./tests/terraform.auto.tfvars
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
## NOTE: this script runs at the end of static test
3-
## Use this to load any configurations after the static test
3+
## Use this to load any configurations after the static test
44
## TIPS: avoid modifying the .project_automation/static_test/entrypoint.sh
55
## migrate any customization you did on entrypoint.sh to this helper script
66
echo "Executing Post-Entrypoint Helpers"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
## NOTE: this script runs at the start of static test
3-
## use this to load any configuration before the static test
3+
## use this to load any configuration before the static test
44
## TIPS: avoid modifying the .project_automation/static_test/entrypoint.sh
55
## migrate any customization you did on entrypoint.sh to this helper script
66
echo "Executing Pre-Entrypoint Helpers"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plan.out.json
44

55
# Local .terraform directories
66
**/.terraform/*
7+
**/.terraform
78

89
# .tfstate files
910
*.tfstate

.header.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
# Terraform Module Project
1+
# Terraform Cloud Agent on Amazon ECS
22

3-
:no_entry_sign: Do not edit this readme.md file. To learn how to change this content and work with this repository, refer to CONTRIBUTING.md
3+
This solution creates self-hosted HashiCorp Cloud Platform (HCP) Terraform agent on Amazon ECS cluster. HCP Terraform allows you to manage isolated, private, or on-premises infrastructure using self-hosted HCP Terraform agents. The agent polls HCP Terraform or HCP Terraform Enterprise for any changes to your configuration and executes the changes locally, so you do not need to allow public ingress traffic to your resources. Agents allow you to control infrastructure in private environments without modifying your network perimeter.
44

5-
## Readme Content
5+
## Architecture
66

7-
This file will contain any instructional information about this module.
7+
![Terraform Cloud Agent on Amazon ECS architecture](/assets/architecture.png)
8+
9+
## Prerequisites
10+
11+
To use this module you need to have the following:
12+
13+
1. [HashiCorp Cloud Platform (HCP) Terraform](https://www.hashicorp.com/products/terraform) subscription
14+
2. Terraform API token with permission to create Terraform agent pool
15+
3. AWS account and credentials to provision resources as mentioned below.
16+
4. VPC with private subnets
17+
18+
## Getting Started
19+
20+
Please refer to the [examples](./examples/basic) on how to get started.

.project_automation/functional_tests/entrypoint.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
## WARNING: DO NOT modify the content of entrypoint.sh
4-
# Use ./config/functional_tests/pre-entrypoint-helpers.sh or ./config/functional_tests/post-entrypoint-helpers.sh
4+
# Use ./config/functional_tests/pre-entrypoint-helpers.sh or ./config/functional_tests/post-entrypoint-helpers.sh
55
# to load any customizations or additional configurations
66

77
## NOTE: paths may differ when running in a managed task. To ensure behavior is consistent between
@@ -22,7 +22,7 @@ pre_entrypoint() {
2222
post_entrypoint() {
2323
if [ -f ${PROJECT_PATH}/.config/functional_tests/post-entrypoint-helpers.sh ]; then
2424
echo "Post-entrypoint helper found"
25-
source ${PROJECT_PATH}/.config/functional_tests/post-entrypoint-helpers.sh
25+
source ${PROJECT_PATH}/.config/functional_tests/post-entrypoint-helpers.sh
2626
echo "Post-entrypoint helper loaded"
2727
else
2828
echo "Post-entrypoint helper not found - skipped"
@@ -32,12 +32,16 @@ post_entrypoint() {
3232
#********** Pre-entrypoint helper *************
3333
pre_entrypoint
3434

35-
#********** Checkov Analysis *************
36-
echo "Running Checkov Analysis"
37-
terraform init
38-
terraform plan -out tf.plan
39-
terraform show -json tf.plan > tf.json
40-
checkov --config-file ${PROJECT_PATH}/.config/checkov.yml
35+
#********** Functional Test *************
36+
/bin/bash ${PROJECT_PATH}/.project_automation/functional_tests/functional_tests.sh
37+
if [ $? -eq 0 ]
38+
then
39+
echo "Functional test completed"
40+
EXIT_CODE=0
41+
else
42+
echo "Functional test failed"
43+
EXIT_CODE=1
44+
fi
4145

4246
#********** Post-entrypoint helper *************
4347
post_entrypoint

.project_automation/functional_tests/functional_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if test -f ${MANDATORY_TEST_PATH}; then
2020
else
2121
echo "File ${MANDATORY_TEST_PATH} not found. You must include at least one test run in file ${MANDATORY_TEST_PATH}"
2222
(exit 1)
23-
fi
23+
fi
2424

2525
if [ $? -eq 0 ]; then
2626
echo "Terraform Test Successfull"

.project_automation/static_tests/entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
## WARNING: DO NOT modify the content of entrypoint.sh
4-
# Use ./config/static_tests/pre-entrypoint-helpers.sh or ./config/static_tests/post-entrypoint-helpers.sh
4+
# Use ./config/static_tests/pre-entrypoint-helpers.sh or ./config/static_tests/post-entrypoint-helpers.sh
55
# to load any customizations or additional configurations
66

77
## NOTE: paths may differ when running in a managed task. To ensure behavior is consistent between
@@ -22,7 +22,7 @@ pre_entrypoint() {
2222
post_entrypoint() {
2323
if [ -f ${PROJECT_PATH}/.config/static_tests/post-entrypoint-helpers.sh ]; then
2424
echo "Post-entrypoint helper found"
25-
source ${PROJECT_PATH}/.config/static_tests/post-entrypoint-helpers.sh
25+
source ${PROJECT_PATH}/.config/static_tests/post-entrypoint-helpers.sh
2626
echo "Post-entrypoint helper loaded"
2727
else
2828
echo "Post-entrypoint helper not found - skipped"

0 commit comments

Comments
 (0)