This is a template for a Terraform project that defines a single stack on AWS.
- Configuration strategy based on per-environment files
- Configure and run inspec tests
- Manage remote state in a Terraform cloud workspace
- Makefile that runs Terraform with the relevant configuration strategies
- Support for running this in a delivery pipeline ** buildspec files for AWS CodePipeline
- AWS profile setup with authentication, including a role to assume
- Terraform cloud token
- Configure the stack
- Configure the Terraform back end
- Apply the stack
Copy and then edit the stack configuration:
cp example-stack.tfvars my-stack.tfvars
Edit my-stack.tfvars
, looking for things in ALLCAPS
and replacing them:
Variable | What to put |
---|---|
environment_name = "sandbox_YOURNAME" | To start with, every developer or pair should use their own sandbox environment, so set this to something unique. |
estate_name = "my_organization" | This is mainly used for tagging and naming things in stacks. |
assume_role_arn = "arn:aws:iam::NNNNNNNNNNNN:role/ROLE_NAME" | The 'NNN...' is the AWS account ID. |
Copy and then edit the configuration files:
cp example-backend.hcl my-backend.hcl
Edit my-backend.hcl
:
- organization is the Terraform cloud organization.
- workspaces corresponds to the stack instance you will be working with. As above, this should be unique for each user or pair working on a local instance. Set it to the same value as the environment_name variable in
my-stack.tfvars
.
- Run
make plan
andmake apply
to taste - Run
make test
for obvious reasons