| name | terraform-cli |
| description | Terraform CLI operations for Azure infrastructure management. USE FOR: terraform init, terraform plan, terraform apply, terraform destroy, state management, module development, tfsec scanning. DO NOT USE FOR: Azure CLI operations (use azure-cli), Kubernetes operations (use kubectl-cli), Helm charts (use helm-cli). |
When to Use
- Validating Terraform configurations
- Planning infrastructure changes
- Applying infrastructure changes (with approval)
- Security scanning IaC
Prerequisites
- Terraform >= 1.5.0 installed
- Azure CLI authenticated
- Backend storage account accessible
- Environment variables: ARM_SUBSCRIPTION_ID, ARM_TENANT_ID
Commands
Format & Validate
terraform fmt -check -recursive -diff
terraform fmt -recursive
terraform init -backend=false
terraform validate
Planning
terraform init -reconfigure
terraform plan \
-var-file=environments/${ENVIRONMENT}.tfvars \
-out=tfplan \
-detailed-exitcode
terraform show -json tfplan | jq '.resource_changes'
Security Scanning
tfsec . --format=json --out=tfsec-results.json
checkov -d . --output-file=checkov-results.json --output=json
State Operations (Read-Only)
terraform state list
terraform state show 'azurerm_kubernetes_cluster.main'
Best Practices
- ALWAYS run
terraform fmt before committing
- ALWAYS run
terraform validate before planning
- NEVER commit .tfstate files
- ALWAYS use -out flag for plans to review
- Use workspaces for environment separation
- Enable state locking with Azure blob lease
Output Format
Provide structured output:
- Command executed with full parameters
- Exit code (0=success, 1=error, 2=changes pending)
- Summary: resources to add/change/destroy
- Warnings or errors with line references
- Recommendations for next steps
Integration with Agents
Used by: @terraform, @security, @test