Hitesh Sahu
Hitesh SahuHitesh Sahu
  1. Home
  2. β€Ί
  3. posts
  4. β€Ί
  5. …

  6. β€Ί
  7. 6 Workflow

Loading ⏳
Fetching content, this won’t take long…


πŸ’‘ Did you know?

🦈 Sharks existed before trees 🌳.

πŸͺ This website uses cookies

No personal data is stored on our servers however third party tools Google Analytics cookies to measure traffic and improve your website experience. Learn more

Loading ⏳
Fetching content, this won’t take long…


πŸ’‘ Did you know?

🦈 Sharks existed before trees 🌳.
Terraform

    AI-AgenticAI

    AI-DeepLearning

    AI-GenAI

    AI-Infrastructure

    AI-Machine-Learning

    AI-Math

    AWS

    Azure

    Hobbies

    kubernetes

    Management

    Programming

    Terraform
    • Terraform Certification Path

    • Terraform Basics

    • Terraform Configuration Management

    • TF Modules: How to Use & Create

    • TF State & Backend Management

    • Terraform Core Workflow & Commands

    • IaC Concepts & TF Overview

    • TF Cloud Capabilities & Workflow

    • TF CMD Cheatsheet

    • Terraform Index


    Z_Appendix

    0-root

Cover Image for Terraform Core Workflow & Commands
Terraform

Terraform Core Workflow & Commands

Learn how to plan, apply, and manage your Terraform infrastructure efficiently.

Terraform
Cloud
Infrastructure as Code
IaC
DevOps
← Previous

TF State & Backend Management

Next β†’

IaC Concepts & TF Overview

Terraform Core Workflow & Commands

Use Terraform outside the core workflow - 14%

  • 4a Describe when to use terraform import to import existing infrastructure into your Terraform state
  • 4b Use terraform state to view Terraform state
  • 4c Describe when to enable verbose logging and what the outcome/value is

Core Terraform workflow - 14%

  • 6a Describe Terraform workflow ( Write -> Plan -> Create )
  • 6b Initialize a Terraform working directory (terraform init)
  • 6c Validate a Terraform configuration (terraform validate)
  • 6d Generate and review an execution plan for Terraform (terraform plan)
  • 6e Execute changes to infrastructure with Terraform (terraform apply)
  • 6f Destroy Terraform managed infrastructure (terraform destroy)
  • 6g Apply formatting and style adjustments to a configuration (terraform fmt)

Initialize your Terraform working directory

command use
terraform init initialize directory, pull down providers
terraform init -get-plugins=false initialize directory, do not download plugins
terraform init -verify-plugins=false initialize directory, do not verify plugins for Hashicorp signature

Format and Validate Terraform code

command use
terraform fmt format code per HCL canonical standard
terraform fmt -diff display diffs of formatting changes
terraform fmt -check -recursive process files in subdirectories
terraform validate validate code for syntax
terraform validate -json produce validation results in JSON format to allow using the validation result for tool integrations,
terraform validate -backend=false validate code skip backend validation

Plan, Deploy and Cleanup Infrastructure

command use
terraform plan -out plan.out output the deployment plan to plan.out
terraform apply plan.out use the plan.out plan file to deploy infrastructure
terraform apply --auto-approve apply changes without being prompted to enter "yes"
terraform plan -destroy outputs a destroy plan
terraform destroy --auto-approve destroy/cleanup deployment without being prompted for β€œyes”
terraform apply -target=aws_instance.my_ec2 only apply/deploy changes to the targeted resource
terraform apply -var my_region_variable=us-east-1 pass a variable via command-line while applying a configuration
terraform apply -lock=true lock the state file so it can't be modified by any other Terraform apply or modification action(possible only where backend allows locking)
terraform force-unlock LOCK_ID unlock state file
terraform apply -refresh=false do not reconcile state file with real-world resources(helpful with large complex deployments for saving deployment time)
terraform apply --parallelism=5 number of simultaneous resource operations (Default 10)
terraform refresh reconcile the state in Terraform state file with real-world resources
terraform providers get information about providers used in current configuration

Terraform Import And Outputs

command use
terraform import aws_instance.new_ec2_instance i-abcd1234 import EC2 instance with id i-abcd1234 into the Terraform resource named "new_ec2_instance" of type "aws_instance"
terraform import 'aws_instance.new_ec2_instance[0]' i-abcd1234 same as above, imports a real-world resource into an instance of Terraform resource
terraform output list all outputs as stated in code
terraform output instance_public_ip list out a specific declared output
terraform output -json list all outputs in JSON format

Terraform workflow

TF workflow is 3 Steps

  1. Write: write IaC
  2. Plan: Preview changes before applying
  3. Apply: Provision Infrastructure

Hitesh Sahu
Written by Hitesh Sahu, a passionate developer and blogger.

Wed Feb 25 2026

Share This on

← Previous

TF State & Backend Management

Next β†’

IaC Concepts & TF Overview

Terraform/6-Workflow
Let's work together
+49 176-2019-2523
hiteshkrsahu@gmail.com
WhatsApp
Skype
Munich πŸ₯¨, Germany πŸ‡©πŸ‡ͺ, EU
Playstore
Hitesh Sahu's apps on Google Play Store
Need Help?
Let's Connect
Navigation
Β  Home/About
Β  Skills
Β  Work/Projects
Β  Lab/Experiments
Β  Contribution
Β  Awards
Β  Art/Sketches
Β  Thoughts
Β  Contact
Links
Β  Sitemap
Β  Legal Notice
Β  Privacy Policy

Made with

NextJS logo

NextJS by

hitesh Sahu

| Β© 2026 All rights reserved.