infrastructure-iac
Skill17 starsChanged 56 days agoMITView on GitHub
Infrastructure as Code best practices for Terraform, Docker, Ansible, and CloudFormation. Covers secure-by-default configurations, multi-stage builds, state management, and modular patterns. Use when working with .tf, Dockerfile, docker-compose.yml, .yaml/.yml Ansible files, CloudFormation templates, or when asking about IaC, containers, or infrastructure automation.
- Installs packages
In this repository53 other files it gives its agents.
- agents-sdkSkill
- agent-workflowSkill
- api-designSkill
- aws-iamSkill
- bash-shell-scriptingSkill
- cicd-github-actionsSkill
- cloudflare-email-serviceSkill
- cloudflareSkill
- cloudflare-waf-authorSkill
- cloudflare-workers-authorSkill
- cloud-platformsSkill
- codebase-security-auditSkill
- containers-orchestrationSkill
- core-engineeringSkill
- database-postgresqlSkill
- databricksSkill
- data-engineeringSkill
- distributed-transactionsSkill
- documentation-standardsSkill
- domain-driven-designSkill
- durable-objectsSkill
- frontend-engineeringSkill
- git-workflowSkill
- go-rust-systemsSkill
- iam-security-advisorSkill
- independent-verificationSkill
- kubernetes-containersSkill
- kubernetes-operator-developmentSkill
- mcp-developmentSkill
- memory-architectureSkill
- multi-perspective-reviewSkill
- networking-transportSkill
- observabilitySkill
- oktaSkill
- pdf-exportSkill
- python-developmentSkill
- reactflow-architecture-diagramsSkill
- sandbox-sdkSkill
- scripting-automationSkill
- security-testingSkill
- service-resilienceSkill
- single-file-dashboardSkill
- skills-compositionSkill
- skills-continuous-improvementSkill
- snowflakeSkill
- system-designSkill
- typescript-javascriptSkill
- web-perfSkill
- web-research-kb-refreshSkill
- workers-best-practicesSkill
- workload-identitySkill
- wranglerSkill
- zero-trustSkill
The file
Files
Infrastructure as Code
Guiding Principles
- Security First: Non-root users, minimal images, secret management
- Reproducibility: Pin versions, deterministic builds, locked dependencies
- Modularity: Reusable modules, DRY patterns, clear interfaces
- State Management: Remote state, locking, backup strategies
Tool Selection
| Use Case | Tool |
| Cloud infrastructure | Terraform |
| Containers | Docker |
| Configuration management | Ansible |
| AWS-native IaC | CloudFormation |
Terraform Quick Reference
Essential Commands
terraform init # Initialize working directory
terraform plan # Preview changes
terraform plan -out=tfplan # Save plan for apply
terraform apply tfplan # Apply saved plan
terraform fmt -recursive # Format all files
terraform validate # Validate configurationCritical Patterns
# 1. Pin provider versions
terraform {
required_version = ">= 1.6.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.60"
}
}
}
# 2. Use for_each for stability
resource "aws_subnet" "private" {
for_each = var.private_subnets # NOT: count
}
# 3. Validate inputs
variable "environment" {
type = string
validation {
condition = can(regex("^(dev|staging|prod)$", var.environment))
error_message = "Must be: dev, staging, prod."
}
}
# 4. Mark sensitive data
variable "db_password" {
type = string
sensitive = true
}
# 5. Lifecycle protection
resource "aws_s3_bucket" "state" {
lifecycle {
prevent_destroy = true
}
}Docker Quick Reference
Multi-Stage Build
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
# Production stage
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
USER node
EXPOSE 3000
CMD ["node", "dist/index.js"]Best Practices
# Pin versions
FROM python:3.14.0-slim-bookworm
# Run as non-root
RUN useradd -m appuser
USER appuser
# Layer optimization
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
# Health check
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost:8080/health || exit 1Naming Conventions
| Tool | Convention | Example |
| Terraform | snake_case | aws_vpc.main |
| Docker | lowercase, hyphens | my-app:1.0.0 |
| Ansible | snake_case | install_packages |
| CloudFormation | Hungarian | pEnvironment, rVpc |
Security Checklist
- No secrets in code (use vaults/secret managers)
- Non-root containers
- Minimal base images
- Version pinning
- Vulnerability scanning
- State encryption (Terraform)
- Network segmentation
Detailed References
- Terraform: See references/terraform.md
- Docker: See references/docker.md
- Ansible: See references/ansible.md
- Configuration: See references/configuration.md
- CloudFormation: See references/cloudformation.md
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.

