AGENT SKILL

infrastructure-as-code

Write and review IaC with Terraform, CloudFormation, Pulumi, or CDK — modularity, security, state management. Triggers: Terraform, CloudFormation, Pulumi, infrastructure as code, IaC, provision, cloud resources, terraform module, state management, terraform plan, CDK, drift, remote state.

License 许可
MIT
最近更新
2026-11-12
Stars
★ 1
Forks
1

01 前言 Front Matter

name
infrastructure-as-code
description
Write and review IaC with Terraform, CloudFormation, Pulumi, or CDK — modularity, security, state management. Triggers: Terraform, CloudFormation, Pulumi, infrastructure as code, IaC, provision, cloud resources, terraform module, state management, terraform plan, CDK, drift, remote state.

02 资源文件 3

03 SKILL.md 正文

Infrastructure as Code

Write and review IaC that is modular, secure, and maintainable. Infrastructure should be treated with the same rigor as application code — versioned, tested, reviewed, and deployed through pipelines.

Workflow

Step 1: Understand the Infrastructure Need

Before writing any IaC:

  • What resources are needed? Compute, storage, networking, databases, queues, CDN?
  • Which cloud provider? AWS, GCP, Azure, or multi-cloud?
  • Which IaC tool? Terraform (cloud-agnostic, declarative), CloudFormation (AWS-native), Pulumi (imperative, multi-language), CDK (AWS, TypeScript/Python)?
  • What environments? Dev, staging, production? How do they differ (instance sizes, replicas)?
  • What exists already? Importing existing resources? Greenfield?

Step 2: Design the Module Structure

Organize IaC for reusability and clarity:

infrastructure/
├── modules/                 # Reusable modules
│   ├── networking/          # VPC, subnets, security groups
│   ├── database/            # RDS, ElastiCache
│   ├── compute/             # ECS, EKS, Lambda
│   └── monitoring/          # CloudWatch, alerting
├── environments/
│   ├── dev/
│   │   ├── main.tf          # Compose modules with dev params
│   │   └── terraform.tfvars
│   ├── staging/
│   └── production/
├── backend.tf               # State backend configuration
└── versions.tf              # Provider version constraints

Each module should be independently usable with well-defined inputs (variables) and outputs.

Step 3: Write the Configuration

Follow these principles. Use templates/terraform-module.md as a starting point for module structure, variables, outputs, and README format.

Modularity: Each module does one thing (networking, database, compute). Modules compose through outputs → inputs.

Parameterization: Use variables for anything that differs between environments. Never hardcode region, instance size, replica count, or credentials.

State management: Use remote state backends (S3 + DynamoDB for Terraform, etc.). Enable state locking. Never commit state files to git.

Security by default: Encrypt at rest, restrict security groups to minimum required ports, use IAM roles (not keys), enable logging.

Tagging: Every resource gets tags for cost allocation, ownership, and environment identification.

Step 4: Review and Validate

Before applying:

  • [ ] terraform plan shows only expected changes
  • [ ] No hardcoded secrets or credentials
  • [ ] Security groups follow least-privilege (no 0.0.0.0/0 ingress on sensitive ports)
  • [ ] Encryption enabled for storage and databases
  • [ ] State backend is remote with locking enabled
  • [ ] All resources are tagged (environment, team, project)
  • [ ] Modules have input validation (variable constraints)
  • [ ] Outputs are defined for values downstream modules need

Step 5: Plan Deployment

  • IaC changes should go through the same PR review process as application code
  • Use plan output as the PR artifact — reviewers should see what will change
  • Apply through CI/CD pipeline, never from a developer's laptop
  • Use workspace or directory-per-environment patterns to prevent accidental cross-environment changes

Principles Applied

  • DRY: Modules eliminate repeated resource definitions across environments.
  • KISS: Start with simple resources, refactor into modules when patterns repeat.
  • YAGNI: Don't create a module for a resource you define once. Modules earn their existence through reuse.
  • Functional Independence: Each module manages its own resources with clean interfaces. No module reaches into another's state.

04 同仓库更多 Skills

SWEStash
SWEStash/swe-workflow-skills

writing-skills

Use when authoring, editing, or reviewing a skill in this library — a new SKILL.md, one that under-triggers, or hardening an existing one. Covers description and listing-budget rules, frontmatter, progressive disclosure, the 3-eval rule, and pressure-testing against rationalizations.

★ 1
SWEStash
SWEStash/swe-workflow-skills

working-agreement

Define and validate how a multi-session project is run — where plans, status and decisions live, session routines, new work, milestone close. README/CONTRIBUTING → project-documentation.

★ 1
SWEStash
SWEStash/swe-workflow-skills

verification-before-completion

Evidence gate before any claim that work is done, fixed, passing, or deployed. Route here when a message declares the work finished or asks to commit, push, merge, ship, or close it out, including a brief sign-off, and before git-workflow or release-management act on it. Writing the commit message or PR text itself → git-workflow.

★ 1
SWEStash
SWEStash/swe-workflow-skills

ui-ux-design

Design user experiences from an engineer's perspective — user flows, wireframes, interaction patterns, responsive strategy, navigation, loading/error/empty states. Triggers: design the UI, user flow, wireframe, how should this screen look, loading state, error state, empty state, responsive design, navigation, page layout, form design, mockup.

★ 1
SWEStash
SWEStash/swe-workflow-skills

threat-modeling

Design-time security analysis of a system or feature before it's built — trust boundaries, attack surface, STRIDE per element, abuse cases, prioritized mitigations that become security requirements. Triggers: threat model, STRIDE, trust boundary, attack surface, what could go wrong security-wise, security design review, abuse case, secure this design, security requirements. Reviewing EXISTING code/config for vulnerabilities → security-audit; use this skill while the design is still on the whiteboard.

★ 1
SWEStash
SWEStash/swe-workflow-skills

test-suite-design

Design comprehensive test suites for existing code — strategy across unit/integration/e2e, fixtures, factories, helpers. Triggers: add tests, write tests for, increase coverage, test this module, testing strategy, test plan, what tests do I need, test infrastructure, test helpers, this has no tests. Not for TDD — use tdd-workflow.

★ 1