A Beginner’s Experience with Terraform
Jamie Barbosa has written this article. More details coming soon.
Before I dive into to Terraform and all its power, I want to make it clear how little I knew about infrastructure before I started working with Terraform and AWS. On our team here at PMG, we like to have everyone be as full-stack as possible so that you’re able to understand what’s going on within a specific tool whether it be infrastructure or frontend related.
This forces us to learn new things all the time, which is awesome.
After becoming pretty comfortable with understanding the codebases I work on and the logic behind it all, it was time to learn some foundational infrastructure. I had spent time in AWS and poked around a bit, knowing in general what services we used and what they were used for but I would say my knowledge level was a solid 4/10. I was tasked with all sorts of infrastructure issues, mostly related to alerting/notifications and setting up auto-scaling groups.
Some of our tools already had some sort of Terraform foundation before I started so I was able to use the existing stuff as a resource, which was pretty helpful. Some of my tasks were easier than others so I decided to tackle the smaller ones first to dip my toes.
There were a few things that were helpful before writing any Terraform stuff. First off, I made sure that I was familiar with the relationships between AWS services, IAM roles and IAM policies. This is the basis of permissions in AWS and knowing how to grant permissions to a service is crucial when working with AWS. Next, I browsed through the existing Terraform modules in our code base and challenged myself to map them back to their services in AWS.
Jumping in, I had to refresh my python skills so that I could write lambda functions for the alerts and notifications. I was able to successfully set up a few different alarms that were triggered by critical application events as well as helpful and friendly notifications for auto-scaling changes. This truly gave us useful insight into our application and the current state that now allows us to manage the application better and prevent errors from occurring.
So what did I learn from this whole journey? AWS is complex, so working with Terraform has a steep learning curve that requires a solid foundation of AWS knowledge. Also, making infrastructure changes may seem scary and unfamiliar at first, but Terraform allows you to organize your application state into files that make sense to you. This means that you can have all of your IAM roles and policies in one place while your services are in another. This becomes super useful as your application grows.
Lastly, lambda functions are just incredible and the possibilities are endless. Want slack alerts for when a service goes down? Done. Want to track metrics and their usage? Done. It’s awesome.
To wrap up, I’ll leave you with some helpful tips for your first Terraform-ing adventure:
Become familiar with AWS first, know the terms, know what things do, and how they work to connect together.
Always plan before applying any changes. Terraform plan will show any immediate issues that you’ll be able to fix before making any real changes.
Separate and organize your Terraform files in a way that makes sense to you and your application.
Start by replicating a few pieces of your existing infrastructure before making changes.
The best way to learn is by doing. Pick what you want to build and go for it!
Stay in touch
Subscribe to our newsletter