For more detailed information, head over to terraform commands docu.
A bunch of scripts, help you to interact with terraform, you can find them in scripts
.
To get an idea what you can do, use:
make help
In order to run compliance checks locally, you first need to login to ECR:
aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 154603002500.dkr.ecr.eu-central-1.amazonaws.com
💡 in general, we strongly advice to interact with terraform locally only in sandbox environments. With all other environments you should consider to interact via pipeline only. This suggestion is in alignment with the GitOps principles, that are proven in the context of infrastructure as code.
This repo comes with an opinionated CI/CD pipline based on github actions. The pipeline supports:
- linting -> improve code quality
- auditing -> meet our compliance rules and guardrails
- deployment -> bring your changes automatically live
- drift detection -> check if your account has any configuration drifts from your infrastructure
See automate Terraform.
- Your Repository must be hosted on github.com
- You need to setup an OIDC IDP in every AWS account that is a target for deployments (see)
- You need an IAM role in the respective AWS accounts with sufficient permissions to execute Terraform (aka. formerly known as technical terraform user)
- Check if deployment meets your requirements
- Set the corresponding values for
<TARGET_ACCOUNT_ID>
- Create an IAM role in the target AWS account with the name
nw-driftctl
- Attach the managed policy
ReadOnlyAccess
- Configure the workflow for driftctl
We encourage you to use Github native Dependabot or Renovate to keep your codebase up to date. We recommend Renovate over Dependabot since it is far more flexible and 100% compatible with this template repository. However Renovate is not available out-of-the box and needs to be enabled manually per repository.
This template comes with an opinionated folder structure, but you are free to change on your behalf.
terraform-blueprint
│ README.md
│ Makefile, etc
│
└───environments
│ │
│ └───sandbox
│ │ terragrunt.hcl --> configuration for sandbox environment
│ │
│ └───preview
│ │ terragrunt.hcl --> configuration for staging environment
│ │
│ └───production
│ terragrunt.hcl --> configuration for production environment
│
└───terraform
│ *.tf --> the actual terraform config files
│
└───scripts
│ *.sh --> utility scripts
│
└───docs
│ *.md --> documentation
│
└───.github
└───workflows
*.yml --> Github pipeline workflows
To add another environment, simply add another folder under environment/
. The folder name equals the name of the
environment. You need to put a terragrunt.hcl
file for terragrunt in the respective folder. Mind to update the
settings according to your environments requirements.
:chocolate_bar: That's it!