Skip to content

Latest commit

 

History

History
128 lines (90 loc) · 2.7 KB

README.md

File metadata and controls

128 lines (90 loc) · 2.7 KB

Terraform Test

POC Project with Terraform IaC. It includes a ECS service running Nginx container and Cognito Authorization.

Architecture

diagram

AWS credentials

Use aws-vault to manage your credentials or another of your preference.

Resources

Name Description
backend resources to configure terraform S3 remote state and lock table
shared shared resources used by applications
modules reusable modules
applications you find all applications here

Requirements

Deployment

There is a order to apply all resources:

  1. backend
  2. shared
  3. applications
aws-vault exec <your-profile> -d 12h --

cd backend
terraform init
terraform plan -out plan.apply
terraform apply plan.apply

cd -
cd shared
terraform init
terraform plan -out plan.apply
terraform apply plan.apply

cd -
cd applications/nginx-app
terraform init
terraform workspace new stg
terraform workspace new prd
terraform plan -out plan.apply
terraform apply plan.apply

cd -

Testing

There is a basic test in test folder.

Verifications

Terraform fmt

terraform fmt --recursive

Checkov

# with local installation
checkov -d .

# with docker
docker run -v $(pwd):/data --rm -it bridgecrew/checkov -d /data --quiet

Running tests

aws-vault exec <your-profile> -d 12h --

cd test
go test

cd -

Clean Up

There is a order to destroy all resources:

  1. applications
  2. shared
  3. backend
cd applications/nginx-app
terraform init
terraform plan -out plan.destroy -destroy
terraform apply plan.destroy

cd -
cd shared
terraform init
terraform plan -out plan.destroy -destroy
terraform apply plan.destroy

cd -
cd backend
terraform init
terraform plan -out plan.destroy -destroy
terraform apply plan.destroy

cd -

Roadmap

  • Add moto for mocked tests
  • Add ECR Repository to build a custom image
  • Automated plan/apply with Atlantis or Github Actions