šŸ”„An Intro to Bootstrapping AWS to Your Terraform CI/CD

Kyler Middleton
The Startup
Published in
2 min readNov 18, 2019

--

This blog series focuses on presenting complex DevOps projects as simple and approachable via plain language and lots of pictures. You can do it!

Pairing Terraform with a CI/CD like Azure DevOps, Terraform Cloud, or GitHub Actions can be incredibly empowering. Your team can work on code simultaneously, check it into a central repo, and once code is approved it can be pushed out by your CI/CD and turned into resources in the cloud.

Photo from Skeeze@Pixabay

When you start rolling this out, you run into an immediate catch22 ā€” you need an S3 bucket for TF state, and a DynamoDB for state locking to run terraform, but you need to run terraform in order to build these resources.

The best method Iā€™ve thought of to get around this problem Iā€™m calling ā€œpivotingā€. The basic order is:

  1. Run terraform from your local machine, and build the S3 bucket, DyanmoDB table, and any other bootstrap items you need.
  2. Tell terraform to use the s3 bucket and DyanmoDB table, and push your local .tfstate to the remote storage.
  3. Upload your terraform to the CI/CD, where it can access its state file and start building other cool things.

Letā€™s walk through the steps, and youā€™ll have an AWS account bootstrapped into your CI/CD before you can say ā€œterraformā€¦

--

--

Kyler Middleton
The Startup

DevNetSecOps, DevRel, cloud security chick. I will teach you, itā€™s unavoidable. She/Her šŸ³ļøā€šŸŒˆšŸ³ļøā€šŸŒˆ, INFJ-A, support the EFF!