We are using Hashicorp’s Terraform because we are in love with the idea called Infrastructure as Code (IaC) and it allows us to deploy, test and change our architectures fast and easy. It allows you to easily use the same configurations in multiple places to reduce mistakes and save time.
Infrastructure as Code, or programmable infrastructure, means writing code to manage configurations and automate provisioning of infrastructure in addition to deployments.
Terraform is a tool designed for creating, managing, updating, and versioning reproducible application infrastructure. It enables you to safely and predictably create, change, and improve infrastructure. It works perfectly with Amazon Web services and also some other lead cloud providers e.g., AWS, Azure, Google Cloud, DigitalOcean).
Deploying a suitable infrastructure has never been easier. No need to click around the console to create a resource or to start over if you mess something up.
Deploying the same infrastructure design in many accounts
We have customers who need to deploy the same infrastructure in many accounts. Before having IaC there was no other option but to go into the AWS Console and create the needed resources one by one. In this particular case this involves doing exactly the same thing over and over again in different accounts.
Our decision was to write one Terraform stack for this infrastructure and deploy it in all the accounts. We think that it is a good idea to stick to one of the best practices - putting as much variables as you can because that guarantees that your code is reusable. For this case this is very important because once you have the stack you want, you can just change the values of your variables and you have a completely new deployment ready.
When it’s likely to have a lot of changes on your infrastructure
We all know that there is no project that has only one version. They all start with some ideas, then new solutions add up to the picture in order to make everything better and have the best result possible.
This includes having an infrastructure that will be changed a lot in the future. The good news is that Terraform has a file called “terraform.tfstate” which shows the state of your infrastructure stored from the last time Terraform was run or applied. This makes your future changes amazingly easy.
Reusable code, reproducible infrastructure
Use one stack to deploy infrastructure in different accounts. You can also easily use the same configurations in multiple places to reduce mistakes and save time.
Easy deployment, shareable modules
It takes only three steps in your terminal - “terraform init”, “terraform plan”, “terraform apply” and you have all your resources created.
Versioned, easy for changing infrastructure
Terraform code can be stored in version control, shared, and collaborated on by teams. If you want to change something small in your resources there is no need to start all over again, just “terraform apply” once again.