Iac
Designs and reviews Infrastructure as Code - Terraform/Pulumi/CloudFormation patterns, state management, module design, change safety, and drift detection. Use when provisioning infrastructure, reviewing IaC changes, or debugging infrastructure issues.From its SKILL.md
npx -y skills add pvnarp/agent-skills --skill iacAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
7.1 KB, ~1.6k tokens by cl100k_base, as published. Nobody here has run it
Infrastructure as Code
IaC makes infrastructure reproducible, reviewable, and version-controlled. It also makes it possible to delete your production database with a typo. Respect the power.
Core Principles
- Everything in code. If it exists in production, it's defined in code. No manual console changes.
- Plan before apply. Always review the diff before making changes. Always.
- Small changes. One concern per PR. Don't refactor modules while adding a new service.
- Immutable infrastructure. Replace, don't mutate. New AMI > patch existing server.
- Blast radius awareness. Know what a change can destroy before you apply it.
Tool Comparison
| Feature | Terraform | Pulumi | CloudFormation | CDK |
|---|---|---|---|---|
| Language | HCL | Python/TS/Go | YAML/JSON | Python/TS |
| State | Remote (S3, etc.) | Pulumi Cloud / self-managed | AWS-managed | AWS-managed |
| Multi-cloud | Yes | Yes | AWS only | AWS only |
| Learning curve | Low-medium | Lower (real language) | Medium | Medium |
| Community | Largest | Growing | AWS-focused | AWS-focused |
Project Structure
infrastructure/
├── modules/ # Reusable modules
│ ├── vpc/
│ ├── database/
│ ├── service/
│ └── monitoring/
├── environments/ # Environment-specific config
│ ├── dev/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ └── terraform.tfvars
│ ├── staging/
│ └── production/
├── global/ # Shared resources (DNS, IAM)
└── README.md
Rules:
- Separate state per environment (dev state can't affect prod)
- Modules are reusable (same module, different parameters per env)
- Environment differences are in variables, not in code duplication
State Management
State is the mapping between your code and real infrastructure. Lose it or corrupt it and you're in trouble.
Remote State (Required for Teams)
# Terraform: S3 + DynamoDB for locking
terraform {
backend "s3" {
bucket = "mycompany-terraform-state"
key = "production/main.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-locks"
encrypt = true
}
}
State Rules
- Never edit state manually (unless you truly understand the consequences)
- Lock state during operations (prevents concurrent modifications)
- Encrypt state at rest (it contains secrets and resource details)
- Separate state per environment (one state file per env)
- Back up state (enable versioning on the state bucket)
State Operations (Use Rarely, Carefully)
# Import existing resource into state
terraform import aws_s3_bucket.my_bucket my-existing-bucket
# Remove resource from state (without destroying it)
terraform state rm aws_s3_bucket.my_bucket
# Move resource within state (rename without destroy/recreate)
terraform state mv aws_s3_bucket.old_name aws_s3_bucket.new_name
Module Design
Good Module
module "api_service" {
source = "../modules/service"
name = "order-api"
environment = "production"
image = "order-api:v1.2.3"
cpu = 512
memory = 1024
port = 3000
replicas = 3
database_url = module.database.connection_string
vpc_id = module.vpc.id
subnet_ids = module.vpc.private_subnet_ids
}
Module Principles
- Inputs are explicit - no hardcoded values inside modules
- Outputs expose what consumers need - connection strings, IDs, ARNs
- Defaults are sensible - dev-friendly defaults, override for prod
- Scope is clear - a module does one thing (a service, a database, a VPC)
- Version your modules - use git tags or registry versions
Change Safety
The Plan Review
terraform plan -out=tfplan # Always save the plan
In the plan output, check:
+ create- new resources (usually safe)~ update in-place- modify existing (review what's changing)-/+ destroy and recreate- DANGEROUS - resource will be deleted and recreated- destroy- DANGEROUS - resource will be deleted
Dangerous Changes (Require Extra Review)
| Change | Risk | Mitigation |
|---|---|---|
| Rename a resource | Destroy + recreate | Use moved block or state mv |
| Change resource type | Destroy + recreate | Import new, remove old from state |
| Modify immutable fields | Destroy + recreate | Check if the field triggers replacement |
| Remove a resource | Deletion | Verify it's truly unused |
| Change database instance type | Potential downtime | Check if it requires restart |
| Modify security groups | Access changes | Review rules before and after |
Protect Critical Resources
resource "aws_rds_instance" "production" {
# ...
lifecycle {
prevent_destroy = true # Terraform will refuse to destroy this
}
}
Secrets in IaC
Never hardcode secrets in IaC files. Not even in .tfvars.
| Approach | How |
|---|---|
| Environment variables | TF_VAR_database_password |
| Secret manager reference | data.aws_secretsmanager_secret_version |
| CI/CD secrets | Injected during pipeline execution |
| SOPS / age | Encrypted files in repo, decrypted at apply time |
Drift Detection
When someone makes a manual change that doesn't match the code:
terraform plan # Shows diff between code and reality
If there's drift:
- Don't just apply - understand what changed and why
- If manual change was correct: update the code to match
- If manual change was wrong: apply to restore code's state
- Prevent future drift: enforce "no console changes" policy, use CI/CD for all changes
CI/CD for Infrastructure
PR opened:
→ terraform fmt -check (formatting)
→ terraform validate (syntax)
→ terraform plan (show what would change)
→ Post plan output as PR comment
PR merged to main:
→ terraform plan (regenerate)
→ Manual approval gate (for production)
→ terraform apply
→ Verify health checks
Rules:
- Never apply without a plan review
- Production requires manual approval
- Plan output visible in PR (reviewers see what will change)
- State locking prevents concurrent applies
Reference:
reference/iac-patterns.md- tool comparison, state management strategies, module patterns, common resource table, drift remediation, secrets handling, tagging strategy.
Review Checklist
- Plan reviewed - no unexpected destroys or recreates
- Secrets not hardcoded (using secret manager or env vars)
- Critical resources have
prevent_destroy - State is remote, encrypted, and locked
- Module inputs are explicit (no hidden assumptions)
- Environment differences are in variables, not code
- Naming is consistent and includes environment
- Tags applied for cost tracking and ownership
What ships with it: 1 file
9.9 KB alongside SKILL.md
reference/
- iac-patterns.md9.9 KB
Gives 0 of the 12 instructions most containers cloud skills give in ~1.6k tokens
Counted across 607 of the 657 authors here whose files we hold, read 2026-08-07
- Run containers as a non-root userin 66 of 607, across 46 files
- Use multi-stage buildsin 53 of 607, across 44 files
- Use Promise.all for independent operationsin 47 of 607, across 13 files
- Import directly instead of barrel filesin 46 of 607, across 12 files
- Use ternary instead of AND for conditionalsin 45 of 607, across 12 files
- Use Set or Map for O(1) lookupsin 42 of 607, across 10 files
- Create a .dockerignore filein 41 of 607, across 31 files
- Read individual rule files for detailsin 39 of 607, across 9 files
- Copy dependency files before source codein 36 of 607, across 23 files
- Authenticate server actions like API routesin 35 of 607, across 7 files
- Use next/dynamic for heavy componentsin 34 of 607, across 9 files
- Use React.cache for per-request deduplicationin 34 of 607, across 10 files
Said here and by no other author read
- Define all production infrastructure in code
- Review the plan diff before applying changes
- Limit each pull request to one concern
- Replace resources instead of mutating them
- Make module inputs explicit
- Version your modules
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.