On Terraform: Up & Running: Writing Infrastructure as Code author Yevgeniy Brikman does an excellent job defending the use of Terraform, a tool designed to make the deployment of infrastructure as code. The book comes with many hands-on examples with all the code available on github for download allowing the reader to follow along.
The author provides answers to questions such as What is Infrastructure as code and What are the benefits of using Infrastructure as code. He provides context of why we are seeing a proliferation of a new set of tools – think Terraform, Packer, Docker, Ansible. He finally show how ties them back to the rise of the DevOps movement.
On DevOps, he uses a definition shared by many, myself included: “The goal of DevOps is to make software delivery more efficient”. The emphasis here is on efficiency and Terraform delivers it.
Throughout the rest of the book the many examples and exercises are set to run on Amazon AWS. Although you can run them someplace else, I would tell you to create an account on AWS and do it there. The examples do follow a logical path. You start with a single server and ending with a cluster of web servers.
To make use of new Terraform concepts, the author makes changes to the initial examples, adopting building blocks available on AWS. These concepts can to different cloud providers and the choice of AWS illustrates the power of Terraform.
One thing to keep in mind, is the fact that there isn’t a simple “brain transfer” between one cloud provider and another. This means that you can’t expect that a specific configuration on one platform will work on another. For example, an Elastic Load Balancers is a specific solution from Amazon and although a similar offer might exist in another place, Terraform can’t guarantee that it will work or act the same.
Terraform uses the HashiCorp Configuration Language (HCL), a declarative language intended to create the infrastructure. “Why should I learn yet another language” you might ask and the answer is: “To make your life easier” and here is why. Terraform can create infrastructure on different platforms such as public and private cloud providers (e.g.: AWS, Azure, DigitalOcean, OpenStack) and virtualization solutions like vSphere. This a core concept in Terraform called providers. Terraform knows how to ‘talk’ to different providers. This takes you away from having to know how to automate these platforms. Instead you can focus on learning one declarative language, HCL. This saves you from having to keep up with CloudFormation, ARM, HEAT, vRealize Automation and others.
Using Infrastructure as Code brings some important considerations. How to provide file isolation, file locking and safeguard the state of the infrastructure managed by Terraform? This brings another point, the trade-offs when using Infrastructure as Code. There are advantages of using Terraform to deploy an infrastructure. Its clear, concise, reproducible method are a plus. The drawback to have in mind is this: when not careful, a commit can break your entire infrastructure. This could be your production and staging environment.
To mitigate potential issues like that, the author shows a few practical approaches. To start, he talks about file isolation and proposes a layout to better organize your code. There’s a chapter deidcated to the use of modules (to avoid code duplication) and version control your code.
If you are new to Terraform this book will bring you up to speed and teaching you about this new and powerful tool. If you have used Terraform before, chances are you can still learn from the vast experience that Yevgeniy brings.
Terraform is a cutting edge tool and it is here to address a complex problem. This book allows you to get the information you need in no time with many examples. Recommended!
To Yevgeniy Brikman: Thank you for writing this book. Staying up to date with a tool still in it’s early days is a challenge. Writing about it must be very hard, so thank you.