Terraform Workflow


Terraform Workflow


Step-01: Introduction

Understand basic Terraform Commands

  1. terraform init
  2. terraform validate
  3. terraform plan
  4. terraform apply
  5. terraform destroy

Step-02: Review terraform manifest for EC2 Instance

  1. Pre-Conditions-1: Ensure you have default-vpc in that respective region
  2. Pre-Conditions-2: Ensure AMI you are provisioning exists in that region if not update AMI ID
  3. Pre-Conditions-3: Verify your AWS Credentials in $HOME/.aws/credentials

Terraform Settings Block

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      #version = "~> 3.21" # Optional but recommended in production

Provider Block

provider "aws" {
  profile = "default" # AWS Credentials Profile configured on your local desktop terminal  $HOME/.aws/credentials
  region  = "us-east-1"

Resource Block

resource "aws_instance" "ec2demo" {
  ami           = "ami-04d29b6f966df1537" # Amazon Linux in us-east-1, update as per your region
  instance_type = "t2.micro"

Step-03: Terraform Core Commands

Initialize Terraform

terraform init

Terraform Validate

terraform validate

Terraform Plan to Verify what it is going to create / update / destroy

terraform plan

Terraform Apply to Create EC2 Instance

terraform apply

Step-04: Verify the EC2 Instance in AWS Management Console

  1. Go to AWS Management Console -> Services -> EC2
  2. Verify newly created EC2 instance

Step-05: Destroy Infrastructure

Destroy EC2 Instance

terraform destroy

Delete Terraform files

  1. rm -rf .terraform*
  2. rm -rf terraform.tfstate*

Step-08: Conclusion

Learned about Important Terraform workflow Commands

  1. terraform init
  2. terraform validate
  3. terraform plan
  4. terraform apply
  5. terraform destroy



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 Workflow
Terraform Workflow
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