Infra - Terraform


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.


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"


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


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

Command Workflow



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

used after:

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


terraform plan


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.


terraform show

inspect the current state


terraform destroy

Powered by ComboStrap