Review: Writing Infrastructure as code with “Terraform up and running” by Yevgeniy Brikman.
If you’re familiar with DevOps, you’ve probably been introduced to building immutable infrastructure with Hashicorp’s tool, Terraform. Originally, I used AWS CloudFormation but switched right after learning about Terraform. Essentially, Terraform is designed specifically for one purpose: to provision infrastructure. Yevgeniy’s book takes you from beginner to advanced in 170 pages.
2 key points that anyone looking into Terraform should consider
- What Terraform is, and how it compares to other IAC tools.
- How Terraform works, and the versatility it provides across multiple cloud platforms (i.e. AWS, Azure, GCP, and IBM)
The Calm Before The Storm
In the first 30 pages, you’ll learn a few things outside of Terraform. Yevgeniy talks about the growth of DevOps. He gives a great breakdown of IAC and the benefits to gain from executing code that defines, deploy and update your infrastructure. Provisioning and managing each component of your environment with code.
There are four broad categories of IAC tools:
- Ad Hoc Scripts
- Configuration Management Tools
- Server Templating Tools
- Server Provisioning Tools
Each category has a section listing tools, an idea of how they’re used, and how the categories differ from each other.
This section also compares Terraform to other popular tools that you can use. Terraform is an open source provisioning tool that works with all cloud providers. It’s immutable, agentless, masterless, has a medium-size community, and use a declarative language.
Yevgeniy uses Amazon’s platform for teaching us the basics. Makes sense, they own the majority of the cloud market. GCP and Azure are gaining ground. It’s still a pretty substantial gap. He walks you through setting up an AWS account, then installing Terraform. You’ll be deploying your first t2.micro instance within the next few pages. The t2.micro instance is a free tier, so take advantage while you can. Before you know it you will deploy a cluster of web servers. You’ll touch autoscaling launch configs, security groups, load balancers and etc.
After the basics, you get a plethora of information that will take you to the next level. You learn what terraform state is and how to manage it. This is very helpful for projects that require multiple people to have access. You’ll see the benefits of creating a reusable infrastructure with Terraform modules. Modules will save time while helping you follow the ideology of keeping things DRY (Don’t Repeat Yourself).
Chapter 5 provides tips while explaining how to use loops, conditionals, and interpolation functions. There’s also a section labeled Terraform Gotchas. Yevgeniy points out a few problems you could easily get hung up on.
The final chapter wraps up how to use Terraform as a team. In a DevOps environment, teamwork & communication are essential to the success of the project. The final chapter focuses on version control, automated testing, coding guidelines, and workflow.
This book isn’t meant to be a replacement for documentation, but it’s a great start to learn terraform and how to optimize your infrastructure. You aren’t going to find a better resource that will give you a better start to using Terraform. Buy the book, read the book, and start building. If the goal is to minimize the amount of time it takes to deliver a product to the customer, then I’m sure you’re interested in IAC. Why not use one of the best tools on the market for it?
terraform apply buyBook.tf
PS: You may find this useful one day. Terraform.