Creating AWS Resources with Terraform : Getting Started

Sagar Kharab
2 min readAug 10, 2020

Terraform is a inarguably one of the efficient tool for building, changing, and versioning infrastructure safely and efficiently. It can manage popular cloud providers as well as custom in-house built resources too..

Terraform uses high level syntax calledHCL (HashiCorp Configuration Language) to interact with cloud apis and resources. It can deliver and manage not only low level resources e.g. Compute Instances, Storage, DataBase Instances but also Networking level resources as well as DNS entries and SaaS features.

Being cloud agnostic and simple Syntax, Terraform sure sweeps some points in it’s bag when compared to other famous IaaC Tools e.g. CloudFormation (AWS service) and Heat (Openstack service).

Some of the Key features of Terraform(official) are as following:

Infrastructure as Code

Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.

Execution Plans

Terraform has a “planning” step where it generates an execution plan. The execution plan shows what Terraform will do when you call apply. This lets you avoid any surprises when Terraform manipulates infrastructure.

Resource Graph

Terraform builds a graph of all your resources, and parallelises the creation and modification of any non-dependent resources. Because of this, Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.

Change Automation

Complex change sets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors.

Follow below steps to install terraform cli:

On macOS

$ brew install terraform

On Linux (Ubuntu)

$ wget /tmp/terraform_linux_amd64.zip https://releases.hashicorp.com/terraform/0.12.29/terraform_0.12.29_linux_amd64.zip --no-check-certificate
$ unzip /tmp/terraform_linux_amd64.zip
$ mv terraform /usr/local/bin
$ rm /tmp/terraform_linux_amd64.zip

verify the installation with

$ brew install terraform
Terraform v0.12.29

Terraform has also released a stable version of v.13 which comes with key support for module driven development using depends_on, count and for_each. Please view below for v.13 updates and installation steps.

https://medium.com/@sagar.kharab/modular-approach-terraform-0-13-2ac5ec6c1714

--

--

Sagar Kharab

Software Developer by profession. Chef by chance. Runner by choice. Sums it all.