Managing Infrastructure at Scale With Terraform
As infrastructure grows, so does the risk that it will not be managed correctly without proper automation.
Join the DZone community and get the full member experience.Join For Free
Eighty percent of software outages are due to improper changes — changes that occurred at the wrong time or were not properly executed.
To reduce these outages, you need to address the core problem: human error. The reality is that repetitive tasks, such as infrastructure configurations, should be designed by humans and executed by software. Having machines tackle the repetitive tasks reduces errors and leaves us to do what we do best — solve problems. This makes our systems more reliable and better designed.
Good news, there is an app for that. Well, a whole open source solution ecosystem, really. Today we are looking at Terraform. Jon Brouse (@jonbrouse) walked through the benefits of Terraform and many code examples in his talk, Terraform at Scale.
Open Source Infrastructure Management
Terraform is an open source infrastructure management project that allows you to safely and predictably create, change, and improve production infrastructure. It is agnostic to the underlying platforms and has over 70 providers. It allows you to write declarative configuration files, treat them as code, and apply version control to them. It is a tool to manage Infrastructure-as-Code — a concept that we hear a lot about because it is central to sound DevOps policies.
In fact, Jon reminds us in his talk that as your system grows, so do the risks. It becomes even more important to reduce human errors. Jon's talk specifically looks at using Terraform at scale with multiple team members, teams, products, and resources.
Use a Style Guide
Jon emphasizes the importance of writing and sticking to a style guide. We aren't talking style sheets, but rather a guide to dictate a consistent style, such as:
- Keeping separate files for each resource and group
- When to use an underscore
- When to use a hyphen
Terraform has validate and format commands to help you check against your style guide and to properly format code.
Jon also discussed Terraform's two types of modules: service and infrastructure. Service modules are a reusable library and create all required resources a service needs to be operational. Infrastructure modules are a single repository comprised of multiple root modules. These are where service modules are instantiated and Terraform is run.
For most of his talk, Jon's walk through code examples in Terraform's language, HCL (Hashicorp Configuration Language), giving you real examples on how to use Terraform.
If you are looking at Terraform as a solution to manage your Infrastructure-as-Code, Jon's talk, below, is well worth 30 minutes of your time.
Published at DZone with permission of Derek Weeks, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.