Azure Terraform CLI
Use this skill to turn Terraform infrastructure requests into ordered CLI workflows, preserve plan and state safety, and return formatting, validation, plan, scan, or read-only state evidence with exit codes and next-step recommendations.
When to invoke
- "Validate or format Terraform configurations."
- "Run terraform init or create a Terraform plan."
- "Summarize resources to add, change, or destroy from a Terraform plan."
- "Inspect Terraform state without changing resources."
- "Run tfsec or Checkov against infrastructure code."
Prerequisites and context
- Terraform >= 1.5.0 installed.
- Azure CLI authenticated.
- Backend storage account accessible.
- Environment variables: ARM_SUBSCRIPTION_ID, ARM_TENANT_ID.
Procedure
- Confirm the working directory, backend mode, environment, and tfvars file before running Terraform commands.
- Run formatting and validation before planning when configuration changes are in scope.
- Initialize with the appropriate backend mode for the requested workflow.
- Create and inspect plans with saved plan files when planning changes.
- Keep state operations read-only unless a separate approved workflow explicitly requires mutation.
- Return the result using the output template.
Format and validate
# Check formatting
terraform fmt -check -recursive -diff
# Apply formatting
terraform fmt -recursive
# Validate configuration
terraform init -backend=false
terraform validate
Planning
# Initialize with backend
terraform init -reconfigure
# Create plan
terraform plan -var-file=environments/${ENVIRONMENT}.tfvars -out=tfplan -detailed-exitcode
# Show plan in JSON
terraform show -json tfplan | jq '.resource_changes'
Security scanning
# TFSec scan
tfsec . --format=json --out=tfsec-results.json
# Checkov scan
checkov -d . --output-file=checkov-results.json --output=json
State operations (read-only)
# List resources
terraform state list
# Show resource details
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 template
Return exactly this structure:
**Status:** PASS | FAIL | BLOCKED
**Summary:** One sentence describing the formatting, validation, plan, scan, state, or infrastructure outcome.
### Details
1. Command executed: `<terraform, tfsec, or checkov command with full parameters>`
2. Exit code: `<0 success, 1 error, 2 changes pending, or tool-specific code>`
3. Workspace or environment: `<workspace, ENVIRONMENT, or tfvars file>`
4. Plan summary: `<resources to add/change/destroy or not applicable>`
5. Warnings or errors: `<line references, scan findings, backend issues, or none>`
6. Recommendations: `<next Terraform action or none>`
### Validation
- Formatting and validation: `<terraform fmt or validate evidence or reason not checked>`
- Plan or state evidence: `<terraform plan, show, state list, state show, scan output, or reason not checked>`
Limits
- Do not use this skill for Azure CLI day-2 commands.
- Use
azure-cli (skill) instead when the task is direct Azure resource queries, AKS credentials, ACR, Key Vault, account context, RBAC checks, or managed identity operations.
- Do not use this skill for Azure architecture design.
- Use
azure-infrastructure (skill) instead when the task is architecture patterns, hub-spoke networking, private endpoints, naming, tagging, or Workload Identity design.
- Do not use this skill for Kubernetes operations.
- Use
kubectl-cli (skill) instead when the task is Kubernetes resource inspection, logs, events, manifests, rollout, or troubleshooting.
- Do not use this skill for Helm charts.
- Use
helm-cli (skill) instead when the task is chart values, repositories, templates, releases, upgrades, or rollbacks.
- Do not use this skill for full deployment orchestration.
- Use
deploy-orchestration (skill) instead when the task spans prerequisites, Terraform apply sequencing, Kubernetes verification, and platform validation.
Related primitives
| Name |
Type |
Use it when |
open-horizons-terraform |
agent |
Designing or implementing Terraform modules and infrastructure changes. |
open-horizons-security-reviewer |
agent |
Reviewing Terraform security, compliance, or policy findings. |
open-horizons-deployment-operator |
agent |
Coordinating approved Terraform execution as part of platform deployment. |
azure-cli |
skill |
Verifying Azure account, resource, AKS, ACR, or Key Vault state outside Terraform. |
azure-infrastructure |
skill |
Choosing Azure architecture patterns before encoding infrastructure. |
validation-scripts |
skill |
Running repository validation after Terraform changes. |
Quality gate
1---2name: azure-terraform-cli-33description: Terraform CLI operations manage Azure infrastructure as code through Terraform formatting, validation, initialization, planning, apply workflows, destroy workflows, state inspection, import workflows, module development, provider lock files, tfvars, and security scanning. Use this skill when working with terraform init, plan, apply, destroy, validate, fmt, state, import, or tfsec workflows.4---56<!-- Generated from harness/github-copilot/plugins/open-horizons-platform/skills/azure-terraform-cli/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# Azure Terraform CLI910Use this skill to turn Terraform infrastructure requests into ordered CLI workflows, preserve plan and state safety, and return formatting, validation, plan, scan, or read-only state evidence with exit codes and next-step recommendations.1112## When to invoke1314- "Validate or format Terraform configurations."15- "Run terraform init or create a Terraform plan."16- "Summarize resources to add, change, or destroy from a Terraform plan."17- "Inspect Terraform state without changing resources."18- "Run tfsec or Checkov against infrastructure code."1920## Prerequisites and context2122- Terraform >= 1.5.0 installed.23- Azure CLI authenticated.24- Backend storage account accessible.25- Environment variables: ARM_SUBSCRIPTION_ID, ARM_TENANT_ID.2627## Procedure28291. Confirm the working directory, backend mode, environment, and tfvars file before running Terraform commands.302. Run formatting and validation before planning when configuration changes are in scope.313. Initialize with the appropriate backend mode for the requested workflow.324. Create and inspect plans with saved plan files when planning changes.335. Keep state operations read-only unless a separate approved workflow explicitly requires mutation.346. Return the result using the output template.3536### Format and validate3738```bash39# Check formatting40terraform fmt -check -recursive -diff4142# Apply formatting43terraform fmt -recursive4445# Validate configuration46terraform init -backend=false47terraform validate48```4950### Planning5152```bash53# Initialize with backend54terraform init -reconfigure5556# Create plan57terraform plan -var-file=environments/${ENVIRONMENT}.tfvars -out=tfplan -detailed-exitcode5859# Show plan in JSON60terraform show -json tfplan | jq '.resource_changes'61```6263### Security scanning6465```bash66# TFSec scan67tfsec . --format=json --out=tfsec-results.json6869# Checkov scan70checkov -d . --output-file=checkov-results.json --output=json71```7273### State operations (read-only)7475```bash76# List resources77terraform state list7879# Show resource details80terraform state show 'azurerm_kubernetes_cluster.main'81```8283### Best practices84851. ALWAYS run `terraform fmt` before committing.862. ALWAYS run `terraform validate` before planning.873. NEVER commit .tfstate files.884. ALWAYS use -out flag for plans to review.895. Use workspaces for environment separation.906. Enable state locking with Azure blob lease.9192## Output template9394Return exactly this structure:9596```markdown97**Status:** PASS | FAIL | BLOCKED98**Summary:** One sentence describing the formatting, validation, plan, scan, state, or infrastructure outcome.99100### Details1011. Command executed: `<terraform, tfsec, or checkov command with full parameters>`1022. Exit code: `<0 success, 1 error, 2 changes pending, or tool-specific code>`1033. Workspace or environment: `<workspace, ENVIRONMENT, or tfvars file>`1044. Plan summary: `<resources to add/change/destroy or not applicable>`1055. Warnings or errors: `<line references, scan findings, backend issues, or none>`1066. Recommendations: `<next Terraform action or none>`107108### Validation109- Formatting and validation: `<terraform fmt or validate evidence or reason not checked>`110- Plan or state evidence: `<terraform plan, show, state list, state show, scan output, or reason not checked>`111```112113## Limits114115- Do not use this skill for Azure CLI day-2 commands.116- Use `azure-cli` (`skill`) instead when the task is direct Azure resource queries, AKS credentials, ACR, Key Vault, account context, RBAC checks, or managed identity operations.117- Do not use this skill for Azure architecture design.118- Use `azure-infrastructure` (`skill`) instead when the task is architecture patterns, hub-spoke networking, private endpoints, naming, tagging, or Workload Identity design.119- Do not use this skill for Kubernetes operations.120- Use `kubectl-cli` (`skill`) instead when the task is Kubernetes resource inspection, logs, events, manifests, rollout, or troubleshooting.121- Do not use this skill for Helm charts.122- Use `helm-cli` (`skill`) instead when the task is chart values, repositories, templates, releases, upgrades, or rollbacks.123- Do not use this skill for full deployment orchestration.124- Use `deploy-orchestration` (`skill`) instead when the task spans prerequisites, Terraform apply sequencing, Kubernetes verification, and platform validation.125126## Related primitives127128| Name | Type | Use it when |129| --- | --- | --- |130| `open-horizons-terraform` | `agent` | Designing or implementing Terraform modules and infrastructure changes. |131| `open-horizons-security-reviewer` | `agent` | Reviewing Terraform security, compliance, or policy findings. |132| `open-horizons-deployment-operator` | `agent` | Coordinating approved Terraform execution as part of platform deployment. |133| `azure-cli` | `skill` | Verifying Azure account, resource, AKS, ACR, or Key Vault state outside Terraform. |134| `azure-infrastructure` | `skill` | Choosing Azure architecture patterns before encoding infrastructure. |135| `validation-scripts` | `skill` | Running repository validation after Terraform changes. |136137## Quality gate138139- [ ] `name` is `terraform-cli` and matches the parent directory.140- [ ] `terraform fmt` and `terraform validate` are run or explicitly marked not applicable before planning.141- [ ] Plans use `-out=tfplan` and report exit code semantics when a plan is created.142- [ ] State operations are read-only unless a separately approved mutating workflow is in scope.143- [ ] Security scan outputs preserve `tfsec-results.json` or `checkov-results.json` paths when scans run.144- [ ] `.tfstate` files are not committed or exposed in the response.