Modular Infrastructure Deployments at New Relic with Terraform
Lisa Moreno from New Relic explains how they take a modular approach to automated AWS infrastructure deployment using HashiCorp Terraform
New Relic is a monitoring company that's primarily focused on monitoring application performance management. It also does infrastructure management, with a product called Infrastructure. The company uses [HashiCorp Terraform]((https://www.hashicorp.com/products/terraform) to deploy it.
Lisa says, "Terraform is a great open-source tool that allows you to create infrastructure with code. … We were a brand-new team; we were tasked with building this new product [with] about a year to do it. … We needed to move quickly but … we wanted to make sure we did something that was clean … easy to use for new people that were coming on, easy to maintain, easy to audit. And Terraform fit the bill for us."
"We modularize as much as possible today, so at the first level we modularize our environments. … For example, we have our Mesos cluster, Cassandra, and Elasticsearch and so on. Each environment also contains an environment module, which hosts our hard-coded values as variables for reuse throughout the modules."
"Everybody … has a hand in maintaining our infrastructure, so we use GitHub Enterprise—all of our code is stored there, including the Terraform'ed state file. … It keeps track of the state of everything you've had in your Terraform code in AWS and so when someone needs to make a change, they make a branch, they make the code change, create a pull request. In that pull request they include the output of
terraform plan which is basically a dry run to see the code changes—here's what's gonna happen. The team has to approve that; once it's approved the engineer runs
terraform apply which actually applies the changes and triggers Terraform to update the state file as well [to] get the freshest state."
"It's really easy to fat-finger—make a mistake—and wipe out an entire cluster. So we really try to limit the blast radius and keep our code as loosely coupled as possible. I personally have wiped out our Cassandra cluster—that thankfully was only in staging—but because of the ease of Terraform, I destroyed it with one command but I also brought it back with another."