Terraform & Devops
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us
No Result
View All Result
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us
No Result
View All Result
Terraform & Devops
No Result
View All Result
Home TERRAFORM CERTIFCATION

Terraform Life cycle

Terraform life-cycle starts from plan , validate, apply, destroy

by abubakarsiddiq858
January 4, 2021
in TERRAFORM CERTIFCATION
177 6
0
Terraform Life cycle
209
SHARES
2.6k
VIEWS
Share on FacebookShare on Twitter

Terraform Life cycle

 

“terraform knows whether to create a resource or destroy or change a resource from its sate file”

Anything that is referred in the resource block is a desired state

Example

resource "aws_instance" "myec2" {
ami = "ami-55555555555"
instance_type = "t2.small"
}

If we make changes for Ami or instance type manually from console for example you are changing instancetype to t2.large in console

 when we do terraform apply  terrforrm changes there will be no effect on resource

its always only to t2.small

Example Usage

provider "aws" {
region = "us-west-2"
access_key = "PUT-YOUR-ACCESS-KEY-HERE"
secret_key = "PUT-YOUR-SECRET-KEY-HERE"
}

resource "aws_instance" "myec2" {
ami = "ami-55555555555"
instance_type = "t2.small"
}
```

Steps involed in Terraform lifeCycle

terraform init

  • initializes the required plugin for the provider
  • when we execute terraform init .terraform directory will be created
  • if no version of the provider is specified latest version will be downloaded when we run terraform init
  • its is not mandatory to specify provider version in resource block
  • to specify a particular version we need to use

provider = version

for example:

version = “2.9” downloads provider 2.9 version

version = “>= 2.7” downloads provider >=2.7

version = “<= 2.10”

version = “>=2.10,<=2.15” downloads any provider version with in specified range

terraform plan

> Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure

> it shows the plan of the resources to be created or destroyed or changed

> there will be no change on terraform state file when you execute terraform plan.

> The only case there is change in state file when we do terraform plan is when we mark a resource as taint

Terraform validate

It validates the synatax of terraform code

terraform apply  

“`

It creates or destroys or changes the resources based on that are the resource terraform  conf file.

Statefile will be effected

Explcit user input yes will be accepted

Terraform destroy

When we do Terraform Destroy  it Destroys resources

Sate file will be effected

Explcit user input yes will be accepted

Saving terraform plan

To save a terraform plan terraform plan –out = hello

To apply  this plan after few days

terraform apply hello

Tags: Business AnalysisGold PriceInvestment LossSillicon ValleyUnited StatedWall Street

Recent News

Implementing VPC Architecture using Terraform

Implementing VPC Architecture using Terraform

August 28, 2021
Build a CICD Pipeline with Git Jenkins Terraform

Build a CICD Pipeline with Git Jenkins Terraform

May 24, 2021

Categories

  • Uncategorized
  • AWS-CLOUD
  • TERRAFORM CERTIFCATION

Site Navigation

  • Home
  • Advertisement
  • Contact Us
  • Privacy & Policy
  • Other Links
Terraform & Devops

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Check our landing page for details.

No Result
View All Result
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us

© 2021 TheTerraform.in - All Rights Reserved.
Designed By TenXinfotech.

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist