Terraform Github Actions Bootstrap
Allows you to bootstrap a Terraform project on AWS using Github Actions. The purpose of the project is to make a simple sandbox for experimenting with Terraform resources using a CI pipeline.
For the companion article, check out: https://www.thedevcoach.co.uk/setup-terraform-aws-github-actions/
Setup Steps
Pre-requisites:
- A setup AWS account
- Git installed on your machine
Step 1: Create the backend bucket
- Clone the repo
git@github.com:loujaybee/terraform-aws-github-action-bootstrap.git
- Install the Terraform binary
- Set your bash variables locally
export AWS_ACCESS_KEY_ID=[your-key]
export AWS_SECRET_ACCESS_KEY=[your-key]
terraform init
to initialise Terraform- Update the
main.tf
file and setbucket
property of the backend and s3 resource blocks (yes, even the one that's commented out, we'll need it as part of step 8) - Execute
terraform apply
(typeyes
)
Step 2: Run Terrafrom on Github Actions
- Uncomment the backend configuration in
main.tf
- Execute
terraform init
(typeyes
to move your state) - Set your AWS
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
as repo secrets @ github.com/[your-username]/[your-repo]/settings/secrets/new git add .
andgit commit -m "First commit"
to commit any changesgit push
to push to github