AgentSkillsCN

tf-plan

为 Azure 基础设施变更生成并审阅 Terraform 执行计划

SKILL.md
--- frontmatter
name: tf-plan
description: Generate and review Terraform execution plan for Azure infrastructure changes
license: MIT
compatibility: opencode
metadata:
  workflow: terraform
  provider: azure

What I do

Generate a Terraform execution plan that shows:

  • Resources to be created
  • Resources to be modified
  • Resources to be destroyed
  • Drift detection from current state

When to use me

Use this skill when:

  • Before applying any infrastructure changes
  • To review what changes Terraform will make
  • To validate configuration changes
  • As part of CI/CD pipeline validation

Commands

bash
# Generate plan with output to terminal
terraform plan

# Save plan to file for later apply
terraform plan -out=tfplan

# Plan for destroy
terraform plan -destroy

# Target specific resources
terraform plan -target=azurerm_resource_group.main

# With variable overrides
terraform plan -var="environment=prod"

# Refresh-only to detect drift
terraform plan -refresh-only

Reading Plan Output

  • + Resource will be created
  • - Resource will be destroyed
  • ~ Resource will be updated in-place
  • -/+ Resource will be destroyed and recreated
  • <= Resource will be read during apply

Best Practices

  1. Always run terraform plan before terraform apply
  2. Save plans to files for production deployments
  3. Review all changes carefully, especially destroys
  4. Use -target sparingly and only when necessary