Useful Terraform commands you need to know🔥

Terraform Initialization Commands:

Initialize Terraform: terraform init
Skip plugin installation: terraform init -get-plugins=false
Force plugin installation from a directory: terraform init -plugin-dir=PATH
Upgrade modules and plugins: ter…


This content originally appeared on DEV Community and was authored by Harshal Rembhotkar

Terraform Initialization Commands:

  1. Initialize Terraform: terraform init
    Skip plugin installation: terraform init -get-plugins=false
    Force plugin installation from a directory: terraform init -plugin-dir=PATH
    Upgrade modules and plugins: terraform init -upgrade

  2. Backend Configuration:
    Update backend configuration: terraform init -migrate-state -force-copy
    Skip backend configuration: terraform init -backend=false
    Use local backend configuration: terraform init -backend-config=FILE
    Change state lock timeout: terraform init -lock-timeout=120s

General Commands:

Terraform Version: terraform version
Download/Update Root Modules: terraform get -update=true
open Interactive Terminal: terraform console
Create Dependency Diagram: terraform graph | dot -Tpng > graph.png
Format Code to HCL Standards: terraform fmt
Validate Code Syntax: terraform validate
Enable Tab Auto-completion: terraform -install-autocomplete
Provider Requirements: terraform providers
Login and Logout: terraform login / terraform logout

Planning Terraform:

Produce a Plan: terraform plan
Output plan for reference: terraform plan -out current.tfplan
Plan for destruction: terraform plan -destroy
Target a specific resource: terraform plan -target=ADDRESS

Applying Terraform:

Apply Current State: terraform apply
Use previously generated plan: terraform apply current.tfplan
Enable auto-approval: terraform apply -auto-approve

Managing Workspaces:

List Workspaces: terraform workspace list
Create New Workspace: terraform workspace new development
Select Workspace: terraform workspace select default

Managing Terraform State:

List Resources in State: terraform state list
Import Resource into State: terraform state import ADDRESS ID
Move Resource in State: terraform state mv SOURCE DESTINATION
Pull State: terraform state pull > terraform.tfstate
Push State: terraform state push PATH
Replace Resource Provider: terraform state replace-provider A B
Taint a Resource: terraform taint ADDRESS
Untaint a Resource: terraform untaint ADDRESS
Show Details of a Resource: terraform state show ADDRESS

Destroying Terraform:

Destroy Managed Resources: terraform destroy
Enable auto-approval: terraform destroy -auto-approve

Outputs:

List Outputs: terraform output
Output a Specific Value: terraform output NAME

Thank you so much for reading❤️.

Catch me up on my socials: https://t.co/M8uECaP62Z


This content originally appeared on DEV Community and was authored by Harshal Rembhotkar


Print Share Comment Cite Upload Translate Updates
APA

Harshal Rembhotkar | Sciencx (2024-09-17T14:38:08+00:00) Useful Terraform commands you need to know🔥. Retrieved from https://www.scien.cx/2024/09/17/useful-terraform-commands-you-need-to-know%f0%9f%94%a5/

MLA
" » Useful Terraform commands you need to know🔥." Harshal Rembhotkar | Sciencx - Tuesday September 17, 2024, https://www.scien.cx/2024/09/17/useful-terraform-commands-you-need-to-know%f0%9f%94%a5/
HARVARD
Harshal Rembhotkar | Sciencx Tuesday September 17, 2024 » Useful Terraform commands you need to know🔥., viewed ,<https://www.scien.cx/2024/09/17/useful-terraform-commands-you-need-to-know%f0%9f%94%a5/>
VANCOUVER
Harshal Rembhotkar | Sciencx - » Useful Terraform commands you need to know🔥. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/17/useful-terraform-commands-you-need-to-know%f0%9f%94%a5/
CHICAGO
" » Useful Terraform commands you need to know🔥." Harshal Rembhotkar | Sciencx - Accessed . https://www.scien.cx/2024/09/17/useful-terraform-commands-you-need-to-know%f0%9f%94%a5/
IEEE
" » Useful Terraform commands you need to know🔥." Harshal Rembhotkar | Sciencx [Online]. Available: https://www.scien.cx/2024/09/17/useful-terraform-commands-you-need-to-know%f0%9f%94%a5/. [Accessed: ]
rf:citation
» Useful Terraform commands you need to know🔥 | Harshal Rembhotkar | Sciencx | https://www.scien.cx/2024/09/17/useful-terraform-commands-you-need-to-know%f0%9f%94%a5/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.