home / skills / partme-ai / full-stack-skills / terraform

terraform skill

/skills/terraform

This skill helps you define and manage infrastructure with Terraform, including resources, modules, state, and provider integration across clouds.

npx playbooks add skill partme-ai/full-stack-skills --skill terraform

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
706 B
---
name: terraform
description: Provides comprehensive guidance for Terraform infrastructure as code including resource definition, state management, modules, and cloud provider integration. Use when the user asks about Terraform, needs to define infrastructure as code, manage cloud resources, or work with Terraform modules.
license: Complete terms in LICENSE.txt
---

## When to use this skill

Use this skill whenever the user wants to:
- [待完善:根据具体工具添加使用场景]

## How to use this skill

[待完善:根据具体工具添加使用指南]

## Best Practices

[待完善:根据具体工具添加最佳实践]

## Keywords

[待完善:根据具体工具添加关键词]

Overview

This skill provides comprehensive, practical guidance for using Terraform to define, deploy, and manage infrastructure as code. It covers resource definitions, state management, module design, and integration with major cloud providers. The guidance is pragmatic and focused on real-world patterns for maintainable, secure, and reproducible infrastructure.

How this skill works

The skill inspects your infrastructure goals and suggests Terraform configurations, module layouts, and state handling strategies tailored to your cloud provider. It explains provider blocks, resource syntax, variables, outputs, workspaces, and remote state backends, and recommends commands and workflows for plan/apply cycles. It also helps diagnose common Terraform errors and suggests fixes for drift, dependency issues, and state corruption.

When to use it

  • When you need to define infrastructure as code for AWS, Azure, GCP, or other supported providers.
  • When you want to design reusable Terraform modules and enforce organization conventions.
  • When managing remote state, workspaces, or multi-environment deployments.
  • When troubleshooting plan/apply failures, resource drift, or state conflicts.
  • When migrating manually provisioned resources into Terraform management.

Best practices

  • Model resources by lifecycle and ownership; keep modules focused and composable.
  • Store remote state in a secure backend (e.g., S3 with locking, Terraform Cloud) and enable encryption.
  • Use variables and input validation; avoid hard-coding credentials or environment-specific values.
  • Pin provider and module versions to avoid unexpected changes from upstream.
  • Review terraform plan output and use automated CI pipelines for apply in shared environments.

Example use cases

  • Create an AWS VPC, subnets, and security groups using reusable modules across environments.
  • Migrate existing cloud resources into Terraform using import and state manipulation guidance.
  • Implement CI/CD pipeline steps: terraform init, plan, and apply with a remote state backend and secrets management.
  • Design multi-account or multi-project layouts using workspaces, backends, and provider aliases.
  • Troubleshoot a failed apply by analyzing dependency graphs, resource taints, and state differences.

FAQ

Can this skill help with Terraform state corruption?

Yes. It outlines safe recovery steps: backup state, inspect remote state, use state rm/mv/import cautiously, and restore from snapshots when necessary.

How do I structure modules for multiple environments?

Use small, single-purpose modules and compose them in environment-specific root configurations. Pass environment differences via variables and keep state isolated per environment/backend.