Justin Rahardjo

Terraform Learnings

By Justin Rahardjo on Apr 28, 2019
Terraform Logo

About a year ago, I learned of the existence of Terraform. I looked into it and realised how powerful it is and the fact that I can minimise the usage of the AWS Console is definitely a plus.

After starting with the basics, Terraform has a great getting started tutorial to follow, I started to think of what I can use this for. I ended up starting to move some of my static S3 websites into it and all the CloudFront infrastructure in. This has actually made my infrastructure so much more repeatable, as I was able to first copy things and once it made sense, I made some modules to keep the infrastructure DRY.

More recently, I started a new project using AWS Lambda, DynamoDB and API Gateways. It was such a great tool to keep all of these different services together and well documented. No more copy-pasting ARNs and policies in the console.

What I’ve learned:

  • It seems obvious now, but when setting up a remote backend, you need to create the S3 and DynamoDB resource before setting the backend.
  • When dealing with a new resource, it helps to manually create one first using the console or the AWS CLI and then try and replicate it with Terraform.
  • Before diving straight into modules and workspaces, have a good think about whether its necessary or not. Just because you have a hammer, doesn’t mean everything is a nail.
  • Don’t be afraid to try things. Its so great to be able to test an infrastructure setup and then destroy it with a couple of commands. Much simpler than bringing things up and down using the console.

I have much more to learn and haven’t even scratched the surface of what is possible with Terraform. So here’s to learning more about it!