infra-terraform
Skill4 starsChanged 5 months agoMITView on GitHub
Modern Terraform patterns for module design, state management, and CI/CD integration. Use for structuring Terraform projects, managing remote state, implementing environment separation, or enforcing code quality.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- PiloTracer/pilo.ai.logicbisontheir own version, first seen Oct 11, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- PiloTracer/pilo.ai.logicbison★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository101 other files it gives its agents.
- ai-video-understandingSkill
- apple-foundation-modelsSkill
- arch-dddSkill
- arch-decision-recordsSkill
- arch-diagramsSkill
- arch-eventsSkill
- arch-mvp-roadmapSkill
- arch-python-modernSkill
- aws-app-runnerSkill
- aws-cicd-patternsSkill
- aws-security-hardeningSkill
- azure-functions-python-v2Skill
- azure-identity-m2m-authSkill
- azure-service-bus-messagingSkill
- azure-workflow-execution-modelsSkill
- caddy-tls-proxySkill
- compliance-frameworksSkill
- design-system-workflowSkill
- dev-debugging-strategiesSkill
- dev-standardsSkill
- docker-python-poetrySkill
- docker-pythonSkill
- fastapi-patternsSkill
- ffmpeg-laravel-videoSkill
- formik-yup-react-nativeSkill
- frontend-accessibilitySkill
- frontend-angular-aiSkill
- frontend-angularSkill
- frontend-angular-toolingSkill
- frontend-design-systemsSkill
- frontend-material-chatSkill
- frontend-material-design-3Skill
- frontend-svelteSkill
- gcp-cicd-patternsSkill
- gcp-cloud-runSkill
- gcp-cloudsql-infrastructureSkill
- gcp-finopsSkill
- gcp-observabilitySkill
- gcp-security-hardeningSkill
- github-actions-cicdSkill
- healthkit-biofeedbackSkill
- ios-app-qualitySkill
- ios-audio-hapticsSkill
- jest-nestjs-testingSkill
- langchain-azure-openai-patternsSkill
- laravel-auth-hardeningSkill
- laravel-ci-mysqlSkill
- laravel-mix-webpackSkill
- laravel-modern-patternsSkill
- laravel-pint-patternsSkill
- laravel-s3-storageSkill
- laravel-sail-dockerSkill
- mobile-app-deploymentSkill
- mobile-e2e-testingSkill
- mobile-offline-syncSkill
- mobile-push-notificationsSkill
- mobile-video-uploadSkill
- mongodb-asyncmongoclient-patternsSkill
- mongodb-atlas-patternsSkill
- nestjs-patternsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 63
EIP association: Import uses the association ID (eipassoc-*), not the allocation ID — retrieve via describe-addresses --query …
- Very specific: line 65
State cleanup: Before removing .tf files, run terraform state rm or terraform destroy -target for each managed resource to prevent orphans
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Terraform Patterns
Modern Infrastructure as Code patterns for Terraform, emphasizing modularity, safety, and team collaboration.
Core Principles
| Principle | Implementation |
| Treat as code | Version control, code review, CI/CD |
| Don't Repeat Yourself | Modules for reusable patterns |
| Explicit > Implicit | tfvars over workspaces, directories over conditionals |
| Plan before apply | Review terraform plan before apply |
| Remote state | Remote state for production environments |
Note: HashiCorp changed Terraform license (BSL). OpenTofu is the community MPL-2.0 fork.
Standard Module Structure
Standard module: main.tf, variables.tf, outputs.tf, versions.tf, README.md + examples/. See reference.md for full directory tree.
Design Guidelines
- Single responsibility - One logical component per module
- Sensible defaults - Work out-of-the-box
- Validate inputs - Catch errors early
- Explicit outputs - Clear contract
- Semantic versioning - Tag releases
State Management
Remote backend required. Enable versioning, locking, encryption, and IAM access control.
| Issue | Solution |
| Lock stuck | terraform force-unlock <ID> |
| Drift detected | Plan shows unexpected changes |
| Import needed | terraform import <resource> <id> |
| State corruption | Restore from versioned backup |
EC2 Import Workflow
Two-phase approach: achieve zero-diff on import first, then apply intentional changes (hardening) as a separate plan/apply.
Pre-Import Reconnaissance
Best practice: capture ground truth via describe-instances, describe-volumes, and describe-addresses before writing HCL. See examples.md for the full reconnaissance command set.
Drift-Prone Attributes (t2/t3)
Missing these causes perpetual plan drift: credit_specification, monitoring, ebs_optimized, root_block_device.throughput, root_block_device.iops.
Import Gotchas
- AMI: Pin as literal string, not
data.aws_ami— data source may resolve to a different AMI, triggering instance replacement (amiis ForceNew) - EIP association: Import uses the association ID (
eipassoc-*), not the allocation ID — retrieve viadescribe-addresses --query 'Addresses[0].AssociationId' - SG rename: AWS SG names are immutable — renaming triggers destroy+recreate. Use
lifecycle { create_before_destroy = true }to avoid traffic gaps - State cleanup: Before removing
.tffiles, runterraform state rmorterraform destroy -targetfor each managed resource to prevent orphans
Pre-Apply Discovery
Accounts with prior manual provisioning may have resources that conflict with Terraform-managed equivalents. Running recon before the first apply surfaces these — see examples.md for pre-apply recon commands.
Import-then-harden workflow: recon live state → match HCL to exact live attributes → terraform import → plan (verify zero-diff) → add intentional changes → apply.
data sources reference existing account-wide singletons (OIDC providers) without claiming ownership. resource blocks claim ownership — if the singleton already exists, the apply fails. See aws-security-hardening skill for OIDC provider details.
ECR Configuration
image_tag_mutability = "MUTABLE" accommodates pipelines that push :latest on every deploy — IMMUTABLE rejects the second push silently. SHA tags still provide traceability. ECR lifecycle policies prune orphaned layers accumulated from MUTABLE tag overwrites.
Gate Selection for Non-Terraform Infrastructure
The plan-cost quality gate assumes infrastructure = Terraform. For shell scripts, systemd units, and CI/CD changes classified under "infrastructure" in aiee/project.yaml, fall back to test-enforcement or peer review when no .tf files are changed.
Anti-Patterns
| Anti-Pattern | Pattern |
| Deployment YAMLs in infrastructure repo | Keep in service repo, reference via handoff doc |
| Templates mixed with live Terraform | Move to docs/deployment-templates/ as reference only |
Static SPA SA in shared cloud_run_service_accounts map | Grant only logging.logWriter + artifactregistry.writer directly (see gcp-security-hardening skill) |
| Workspaces for environment separation | Directory per environment or tfvars files |
| Write code first, then import existing resources | Import to state first, then write matching code |
IAM for_each block not audited when service gains new dependency | Cross-reference ALL secrets in staging YAML against service's IAM *_secrets block On every deploy |
| Claiming Terraform output is a blocker without checking deploy mechanism | Read the actual deploy pipeline to verify how values are consumed before declaring outputs missing |
| Assuming greenfield on accounts with history | Run pre-apply recon commands before first apply |
Using resource for OIDC provider without checking existence | data source by default; see aws-security-hardening for OIDC provider details |
image_tag_mutability = "IMMUTABLE" with :latest push strategy | Use MUTABLE if pipeline pushes :latest; SHA tags provide traceability |
plan-cost gate on non-Terraform infrastructure changes | Fall back to test-enforcement or peer review for shell/systemd/CI changes |
Critical Rules
- Secrets in tfvars get committed to VCS and leak on any repo clone — store them in Secret Manager and reference dynamically.
- Unlocked provider versions resolve to different releases across machines — commit
.terraform.lock.hclso every run is deterministic. - Unreviewed plans destroy production resources without warning — read every plan output, especially lines prefixed with
-. - Untagged module references (
?ref=main) pull breaking changes silently — pin with?ref=v1.2.3and treat upgrades as explicit decisions. - Drift discovered at apply time means a human is in the loop under pressure — running
planin CI surfaces drift before it becomes an incident. Seereference.mdfor environment separation patterns, state safety, state lock prevention, zero-downtime migration, IAM binding placement, deployment process, cross-repo secret validation, and multi-phase ticket validation.
See examples.md for complete module examples, CI/CD pipelines, Makefile patterns, and pre-commit configuration.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

