Terraform -AWS Installation


Install awscli for Linux

  1. curl "" -o ""
  2. unzip
  3. sudo ./aws/install
  4. aws --version

Aws Configuration (rprofile is the name of the profile)

  1. aws configure 
  2. aws iam list-users 

Install Terraform on ubuntu

  1. curl -fsSL | sudo apt-key add -
  2. sudo apt-add-repository "deb [arch=$(dpkg --print-architecture)] $(lsb_release -cs) main"
  3. sudo apt install terraform

Terraform Basics

  1. First Terraform file
  2. What is statefile and its importance
  3. Different ways to give access to tf
  4. Terraform Variables and its usages
  5. Terraform input variables
  6. Terraform output variables

terraform init

terraform plan

terraform apply

terraform destroy

Terraform State file


Example1 - Create an empty terraform file(.tf)

  • Create an empty directory called( say 01)
  • Goto 01 directory (cd 01)
  • Create an empty file called
  • run command terraform init
  • run command terraform plan
  • run command terraform apply it should create terraform.tfstate file

Example2 - Create a provider aws

  • Add following code
    provider "aws"{
  • run command terraform init command
  • it will create .terraform directory for aws plugins


The AWS provider offers a flexible means of providing credentials for authentication. The following methods are supported, in this order, and explained below:

  1. Static credentials
  2. Environment variables
  3. Shared credentials/configuration file
  4. CodeBuild, ECS, and EKS Roles
  5. EC2 Instance Metadata Service (IMDS and IMDSv2)

Static credentials

Static credentials can be provided by adding an access_key and secret_key in-line in the AWS provider block:


provider "aws" {
  region     = "us-west-2"
  access_key = "my-access-key"
  secret_key = "my-secret-key"

Example (To create an EC2 instance with a key)

provider "aws" {
  region     = "ap-south-1"
  access_key = "AKIAZYCCNWPBYU7NQN7M"
  secret_key = "BeO52msn/TiT3p1YrE1xkpnMsHokSEzLiCR0ZL/u"
resource "aws_instance" "example" {
  ami           = "ami-041db4a969fe3eb68"
  instance_type = "t2.micro"
  key_name = "devops"
  tags = {
    Name = "HelloWorld"



Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,ELK,2,git,2,Jira,1,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
DevOpsWorld: Terraform -AWS Installation
Terraform -AWS Installation
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content