← Back to CLIs
Melvynx

terraform

Infrastructure as Code CLI - plan, apply, destroy infrastructure, manage state and workspaces. Use when user mentions 'terraform', 'infrastructure as code', 'IaC', or wants to manage cloud infrastructure declaratively.

Install

$ npx api2cli install terraform

Details

Skill type: Official CLI
Auth type: bearer
Version: 1.0.0
Author: Melvynx
Views: 0

README

terraform

Setup

brew install terraform

Verify installation:

terraform --version

Resources

Workflow

CommandDescription
terraform initInitialize working directory and download providers
terraform init -upgradeUpgrade providers to latest allowed versions
terraform planPreview changes without applying
terraform plan -out=tfplanSave plan to a file
terraform applyApply changes with confirmation prompt
terraform apply -auto-approveApply changes without confirmation
terraform apply tfplanApply a saved plan file
terraform destroyDestroy all managed infrastructure
terraform destroy -auto-approveDestroy without confirmation
terraform destroy -target=aws_instance.exampleDestroy a specific resource

Validation and Formatting

CommandDescription
terraform fmtFormat configuration files
terraform fmt -recursiveFormat files in all subdirectories
terraform fmt -checkCheck formatting without modifying
terraform validateValidate configuration syntax

State Management

CommandDescription
terraform showShow current state or a saved plan
terraform show -jsonShow state as JSON
terraform state listList all resources in state
terraform state show <resource>Show details of a resource in state
terraform state mv <source> <destination>Move a resource in state
terraform state rm <resource>Remove a resource from state
terraform state pullPull remote state to stdout
terraform state pushPush local state to remote

Import and Output

CommandDescription
terraform import <resource> <id>Import existing infrastructure into state
terraform outputShow all output values
terraform output <name>Show a specific output value
terraform output -jsonShow outputs as JSON

Workspaces

CommandDescription
terraform workspace listList all workspaces
terraform workspace showShow current workspace
terraform workspace new <name>Create a new workspace
terraform workspace select <name>Switch to a workspace
terraform workspace delete <name>Delete a workspace

Other

CommandDescription
terraform graphGenerate a visual dependency graph
terraform providersShow required providers
terraform refreshRefresh state against real infrastructure
terraform taint <resource>Mark a resource for recreation
terraform untaint <resource>Remove taint from a resource

Global Flags

FlagDescription
-var 'key=value'Set a variable value
-var-file=<file>Load variables from a file
-target=<resource>Target a specific resource
-parallelism=<n>Limit concurrent operations
-jsonOutput in JSON format
-no-colorDisable colored output
Sponsors