You must have an IAM user set up with the following IAM policies attached:
PowerUser
IAMFullAccess
Generate access credentials (in the form of a user access key and a secret key) for the above user.
Use the following commands to tell Terraform to deploy infrastructure with your user:
export AWS_ACCESS_KEY_ID=<access key from above step>
export AWS_SECRET_ACCESS_KEY=<secret access key>
Change into the infrastructure directory using cd infrastructure.
terraform init
terraform plan -var-file=staging.tfvars
After verifying everything looks good from the above plan, run a terraform apply -var-file=staging.tfvars and confirm.
Make sure infrastructure deploys correctly.
2. Deploy Atlantis
Configure the following environment variables so you are not passing these variables as plaintext in to this Github repository. Instructions for creating a Github user token can be found here, while instructions for generating the webhook secret can be found here:
export TF_VAR_github_user_token=<token>
export TF_VAR_github_webhook_secret=<secret>
Change into the Atlantis directory using cd atlantis.
terraform plan (no environment file this time as it's using the infrastructure you set up above)
terraform apply
Make sure infrastructure deploys correctly.
3. Configure Webhook
You must own a domain that Atlantis can use to interface with. This repository is using "aws.laiello.com" for demonstration purposes, but you will need your own if you fork this repository or wish to use it for a different project. Once you have it created, make sure you change the variable in atlantis/variables.tf to match the new domain.
You must create an ACM certificate to allow HTTPS using the domain you created above.
Configure the webhook as shown in this document. The URL in this case is aws.laiello.com (and is actually configured for this repo in that way) but if you use your own domain, this must be changed to reflect the new domain.
Usage
Create a branch with your infrastructure changes. For example: git checkout -b branch-name-here.
Make and push changes.
Once finished, create a PR.
Atlantis is used within the PR. Please follow these docs which explain how to use Atlantis.
Close the PR and delete the branch. This step can be automated by modifying the atlantis.yaml file. Set automerge: true.