Infra - Terraform

Card Puncher Data Processing

About

Terraform is an orchestration tool that will bootstrap, initialize resources and can start a configuration management tool

Configuration Management

Terraform is not a configuration management tool Using provisioners, Terraform enables any configuration management tool to be used to setup a resource once it has been created.

Installation

choco install terraform
  • Test it
terraform version
Terraform v0.12.1

Configuration Syntax

Terraform configurations can contain multiple resources, multiple resource types, and these types can even span multiple providers.

provider block

  • provider block is used to configure the named provider
provider "aws" {
  access_key = "ACCESS_KEY_HERE"
  secret_key = "SECRET_KEY_HERE"
  region     = "us-east-1"
}

Each “Provider” is its own encapsulated binary distributed separately from Terraform itself.

Resource Block

The resource block defines a resource that exists within the infrastructure.

resource "aws_instance" "example" {
  ami           = "ami-2757f631"
  instance_type = "t2.micro"
}

where:

  • aws_instance is the resource type with the aws prefix defining the provider.
  • example is the resource name.
  • the block defines the resource configuration

State

Terraform wrote some data into the terraform.tfstate file.

terraform show shows the current state

This state file is extremely important; it keeps track of the IDs of created resources so that Terraform knows what it is managing.

This file must be saved and distributed to anyone who might run Terraform.

It is generally recommended to setup remote state when working with Terraform, to share the state automatically.

Every Terraform setup has two parts:

  • .tf files describing the ideal state
  • .tfstate files describing the current state.

Command Workflow

Init

init:

  • initializes local settings, data,
  • download and install any Provider

used after:

  • a version control check out
  • or a configuration file modification
terraform init

Plan

terraform plan

Apply

terraform apply

The output format is similar to the diff format generated by tools such as Git.

  • The + prefix indicates that the resource will be created.
  • The - prefix indicates that the resource will be destroyed.

Show

terraform show

inspect the current state

Destroy

terraform destroy





Discover More
Card Puncher Data Processing
Aws - Client

Client of Aws can create resources on the Aws platform ansible Boto - A Python interface - A ruby interface
Card Puncher Data Processing
Infrastructure as code Application

Application This section is composed of the applications that you can use to implement a infrastructure as code
Card Puncher Data Processing
Orchestration

A orchestration tool will provision the servers or container themselves, leaving the job of configuring those servers to other configuration management tool. It's part of a set of tool to support infrastructure...
Card Puncher Data Processing
What is Infrastructure as code? (Configuration, Provisioning, and Software Deployment)

Infrastructure as code means that all ops operations are scripted and are found in code. They are used in DevOps pipeling for continuous deployment You will find three kind of software in this area:...



Share this page:
Follow us:
Task Runner