{{announcement.body}}
{{announcement.title}}

Build Infrastructure as Code Efficiently With an Open Source Terraform Accelerator

DZone 's Guide to

Build Infrastructure as Code Efficiently With an Open Source Terraform Accelerator

In this article, we discuss how a Terraform Accelerator can be used to build your AWS and Azure infrastructures faster and easier.

· DevOps Zone ·
Free Resource

An open-source Terraform accelerator is a set of proven code and a platform that organizations can use to build their AWS and Azure infrastructures faster.

Organizations can pick which part of the infrastructure they want to build at what time and choose services accordingly. In addition to requiring smaller teams, this allows for incremental improvements and greater stability. Engineers can deploy infrastructure using the Terraform Accelerator using just one command. They can have an entire infrastructure deployed in around half an hour. This previously took 10 hours using the basic Terraform tool. 

A streamlined Terraform process in code allows for deployments to get done faster. Terraform is an open-source infrastructure as code software tool created by HashiCorp. It enables users to define and provision a data center infrastructure using a high-level configuration language, known as Hashicorp Configuration Language (HCL). This can also be done with JSON.

Infrastructure as code (IaC) can be a key attribute of enabling best-practices in DevOps because developers become more involved in defining configuration, and Ops teams get involved earlier in the development process. Tools that enable IaC bring visibility to the state and configuration of servers and ultimately provide the visibility to users within the enterprise. 

The automation within the Terraform Accelerator takes the toil and error-prone aspect of manual processes and makes it more efficient and productive. Applications can be created with flexibility, less downtime, and overall cost-effectiveness. IaC reduces the complexity out of manual configuration. Automation and collaboration are considered central points in DevOps, Infrastructure automation tools are often included as components of a DevOps toolchain, and now, highly automated accelerators can be added to the mix.

An organization should pick and choose which Cloud services they want based on what best serves their needs at the time and scale up and down over time. They're not locked into using a service or tool if they don't need it. They can just exclude it, and it's not a big deal because of the push-button nature of the tool. An accelerator enhances elasticity.  

How it Works 

You clone the repository using Git. You can then set up a database that Terraform uses with Terraform init. It'll give you a message depending on whether that succeeds.

Then, based on what modules you choose to use because you can exclude certain modules if you don't need them, you can type, Terraform plan, and then it will give you a list of all of the different kinds of infrastructure available. From there, you can customize various configuration options before you run a Terraform plan. 

If you know you want to use certain subnets for your availability zones, that's all configurable, and you can configure that before you deploy it. It just became a lot easier to more rapidly deploy public cloud resources and modules. A Terraform accelerator should be extensible too, so if you decide you need more capacity, be it EKS clusters, EC2 instances, or anything else, those are also easy to add after the initial configuration.  

The biggest issue when using Terraform is how to manage the state database that gets created. This is the database that Terraform uses to manage the resources that are actively deployed. Depending on your architecture, you may have to institute database locks in order to manage this database across a distributed team; otherwise, a team will run into conflicts when trying to deal with different resources being deployed by different engineers. For example, if engineers are using the Postgres backend, a team should institute database locks so that one team can’t override another’s changes. Many teams often configure Terraform to work with an S3 bucket and host their state files there.

RDS is another AWS offering that can be tricky to configure for first-time Terraform users, but an accelerator smooths out a lot of these rough edges by supporting PostgreSQL and MySQL out of the box. It can also be configured to work with Aurora, which is AWS’s Serverless PostgreSQL offering. The EKS configuration should also interface with ECR very easily, allowing teams that use Docker to make it much easier to use their Docker images with EKS.  For example:

Properties files
 






 

Big Data platforms, like Vertica and Redis, can also be supported more easily now with Terraform, but watch the costs! Redis becomes easier to spin up because the AMI images aren’t very large, but the Vertica AMI image and its configuration are very large, so you need several TB worth of ECB instances to use it. Be careful because the AMI images used are at least 15GB. If you choose to use these platforms in this manner, be aware of the inherent infrastructure costs that are built into AWS. For example:

Properties files
 






 

Look for as much flexibility as possible to give DevOps teams the tools they need to be maximally successful right away, not in two weeks or a month. The most commonly used modules that really save a lot of time are the security groups, and there are public and private security groups. 

The accelerator should have two EC2 instance choices. One is used for Kafka and another used for Zookeeper, which is surprisingly popular. Look for subnet security, including subnet groups and security groups to manage all those. Look for EKS and then all the infrastructure that manages that. Those are the biggest pieces. We’ve seen bits and pieces of it, but now we use a comprehensive package, which is nice because it's essentially one-stop shopping. Basically, if you've decided on Terraform to automate cloud resources, you've seen the benefits that it can have. If you haven't decided on Terraform, you might want to. 

Summary

A Terraform based cloud accelerator platform can help organizations dramatically reduce the time it takes to deploy numerous aspects of cloud infrastructure, all from one infrastructure as codebase.

This trend will only keep accelerating as time goes on. If organizations are pivoting to the cloud, it behooves them to take advantage of it to reduce their deployment costs.

An accelerator is available at https://github.com/XOPSbuilds/terraform-clean-infra. (This one is in a private repo, so please check with the authors for permission.)

You can use the accelerator with:

  • Kubernetes 
  • Kafka
  • EC2
  • Docker
  • ECR 
  • Fargate 
  • RDS
  • Lambda
  • Azure Virtual Machines
  • Virtual Machine Sets.
  • Azure Container Instances
  • Azure Container Registry
  • Azure Kubernetes Service
  • Azure Functions
  • Azure SQL Database
  • Azure X-Ray
Topics:
aws and devops ,azure ,devops ,infrastructure as a code ,sre ,terraform

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}