Build Infrastructure as Code Efficiently With an Open Source Terraform Accelerator – DZone DevOps | xxxBuild Infrastructure as Code Efficiently With an Open Source Terraform Accelerator – DZone DevOps – xxx
菜单

Build Infrastructure as Code Efficiently With an Open Source Terraform Accelerator – DZone DevOps

二月 29, 2020 - MorningStar

Over a million developers have joined DZone.

  • Build Infrastructure as Code Efficiently With an Open Source Terraform Accelerator - DZone DevOps

    {{node.title}}

    {{node.type}} · {{ node.urlSource.name }} by

    Download {{node.downloads}}

  • {{totalResults}} search results

{{announcement.body}}

{{announcement.title}}

Let’s be friends:

1024)” dc-slot=”ads.sl1.slot(articles[0], 0)” tags=”ads.sl1.tags(articles[0], 0)” size=”ads.sl1.size(articles[0], 0)” style=”border:0px;”>
1 && !articles[0].partner.isSponsoringArticle && (width > 1024)” dc-slot=”ads.sb2.slot(articles[0], 0)” tags=”ads.sb2.tags(articles[0], 0)” size=”ads.sb2.size(articles[0], 0)”>

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.

Build Infrastructure as Code Efficiently With an Open Source Terraform Accelerator - DZone DevOps by

CORE ·

Apr. 07, 20 · DevOps Zone ·

Free Resource

Join the DZone community and get the full member experience.

Join For Free

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

 

xxxxxxxxxx
1

20

 

1

resource "aws_db_instance" "default" {

2

  count = var.enabled ? 1 : 0

3

  identifier = module.label.id

4

  name = var.database_name

5

  username = var.database_user

6

  password = var.database_password

7

  port = var.database_port

8

  engine = var.engine

9

  engine_version = var.engine_version

10

resource "aws_db_instance" "default" {

0

11

resource "aws_db_instance" "default" {

1

12

resource "aws_db_instance" "default" {

2

13

resource "aws_db_instance" "default" {

3

14

resource "aws_db_instance" "default" {

4

15

resource "aws_db_instance" "default" {

5

16

resource "aws_db_instance" "default" {

6

17

resource "aws_db_instance" "default" {

7

18

resource "aws_db_instance" "default" {

8

19

resource "aws_db_instance" "default" {

9

20

  count = var.enabled ? 1 : 0

0

 

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

 

  count = var.enabled ? 1 : 0

1

1

18

 

1

  count = var.enabled ? 1 : 0

2

2

  count = var.enabled ? 1 : 0

3

3

  count = var.enabled ? 1 : 0

4

4

  count = var.enabled ? 1 : 0

5

5

  count = var.enabled ? 1 : 0

6

6

  count = var.enabled ? 1 : 0

7

7

  count = var.enabled ? 1 : 0

8

8

  count = var.enabled ? 1 : 0

9

9

  identifier = module.label.id

0

10

  identifier = module.label.id

1

11

  identifier = module.label.id

2

12

  identifier = module.label.id

3

13

  identifier = module.label.id

4

14

  identifier = module.label.id

5

15

  identifier = module.label.id

6

16

  identifier = module.label.id

7

17

  identifier = module.label.id

8

18

  identifier = module.label.id

9

 

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:
terraform ,infrastructure as a code ,azure ,aws and devops ,devops ,sre

Opinions expressed by DZone contributors are their own.

DevOps Partner Resources

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

{{ parent.tldr }}

{{ parent.linkDescription }}

{{ parent.urlSource.name }}

by

CORE

· {{ parent.articleDate | date:’MMM. dd, yyyy’ }} {{ parent.linkDate | date:’MMM. dd, yyyy’ }}


Notice: Undefined variable: canUpdate in /var/www/html/wordpress/wp-content/plugins/wp-autopost-pro/wp-autopost-function.php on line 51