Skip to main content


Showing posts from June, 2022

Terraform: Understanding Desired & Current State

In this post, we will learn in detail what is terraform desired and current state. Terraform’s responsibility is to create/update/destroy infrastructure resources to match the desired state as described in the configuration. Desired State: For example: If our desired state is as below resource "aws_instance" "myec2" { ami = "ami-0ca285d4c2cda3300" instance_type = "t2.medium" } This should result in an AWS EC2 t2.medium instance. The code you saw above is the desired state that we want. Current State: The current state is the actual state of a resource that is deployed. For example: If our desired state is as below resource "aws_instance" "myec2" { ami = "ami-0ca285d4c2cda3300" instance_type = "t2.medium" } our desired state is t2.medium instance but let’s say the current instance running is t2.micro. So it means our desired state and the current state is not matching. Try it out

Terraform - 101

In this post, we will learn the basics of Terraform. We will launch a AWS EC2 instance using terraform. What is Terraform? HashiCorp Terraform is an open source infrastructure as code ( IaC ) software tool that allows DevOps engineers to programmatically provision the physical resources an application requires to run. Read more here: Prerequisite: For this tutorial, you will need. AWS Account Download and install Terraform . Let’s start Log in to AWS and create an IAM Role which we will use with terraform. Get the access_key and access_secret this is required. Create a new project directory. Inside the directory create a file   and past the following code. provider "aws" { region = "us-west-2" access_key = "<YOUR_ACCESS_KEY>" secret_key = "<YOUR_SECRET_KEY>" } resource "aws_instance" "myec2" { ami = "ami-0ca285d4c2cda3300" instance_type =