Provides Infrastructure as Code best practices for Terraform, Pulumi, CloudFormation, and OpenTofu. Use when provisioning infrastructure, writing IaC modules, managing cloud resources, scanning for misconfigurations, or when user mentions 'terraform', 'pulumi', 'cloudformation', 'IaC', 'opentofu', 'infrastructure', 'tfsec', 'checkov', 'drift'.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Provides Infrastructure as Code best practices for Terraform, Pulumi, CloudFormation, and OpenTofu. Use when provisioning infrastructure, writing IaC modules, managing cloud resources, scanning for misconfigurations, or when user mentions 'terraform', 'pulumi', 'cloudformation', 'IaC', 'opentofu', 'infrastructure', 'tfsec', 'checkov', 'drift'.
type
skill
category
patterns
status
stable
origin
tibsfox
modified
false
first_seen
"2026-02-07T00:00:00.000Z"
first_path
examples/infrastructure-as-code/SKILL.md
superseded_by
null
Infrastructure as Code
Best practices for managing cloud infrastructure declaratively with Terraform, Pulumi, CloudFormation, and OpenTofu. Covers module composition, state management, security scanning, and drift prevention.
IaC Tool Comparison
Choose the right tool based on team skills, cloud strategy, and operational requirements.
Tool
Language
State Management
Multi-Cloud
Learning Curve
Ecosystem
Terraform
HCL
Remote backend (S3, GCS, etc.)
Excellent
Medium
Largest provider ecosystem
OpenTofu
HCL
Same as Terraform
Excellent
Medium
Fork-compatible with Terraform
Pulumi
TypeScript, Python, Go, C#
Pulumi Cloud or self-managed
Excellent
Low for developers
Growing, SDK-based
CloudFormation
YAML/JSON
AWS-managed
AWS only
Medium
Native AWS integration
CDK
TypeScript, Python, Java, Go
AWS-managed (synths to CFN)
AWS only
Low for developers
Leverages CFN resources
Decision Factor
Recommendation
Multi-cloud required
Terraform or Pulumi
AWS-only shop
CloudFormation or CDK
Team knows TypeScript
Pulumi or CDK
Need open-source license
OpenTofu
Existing Terraform codebase
Stay Terraform or migrate to OpenTofu
Complex logic and loops
Pulumi (general-purpose language)
State Management Patterns
State is the source of truth for what IaC has provisioned. Mismanaging state causes orphaned resources, duplicate deployments, and data loss.
Drift occurs when actual infrastructure diverges from IaC state. Left unchecked, drift causes failed applies, security gaps, and configuration inconsistencies.
Drift Cause
Prevention
Manual console changes
Lock down console write access; read-only for debugging
Auto-scaling events
Use lifecycle { ignore_changes } for dynamic attributes
External automation
Coordinate with IaC or import resources
Incomplete IaC coverage
Import existing resources before managing them
Drift Detection Strategy
# .github/workflows/drift-detection.ymlname:DriftDetectionon:schedule:-cron:'0 6 * * *'# Daily at 6 AM UTCjobs:detect-drift:runs-on:ubuntu-lateststrategy:matrix:environment: [dev, staging, prod]
steps:-uses:actions/checkout@v4-uses:hashicorp/setup-terraform@v3with:terraform_version:1.7.0-name:TerraformInitworking-directory:./environments/${{matrix.environment}}run:terraforminit-input=false-name:DetectDriftid:planworking-directory:./environments/${{matrix.environment}}run:|
terraform plan -detailed-exitcode -input=false 2>&1 | tee plan_output.txt
echo "exit_code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
# Exit code 0 = no changes, 1 = error, 2 = drift detected
continue-on-error:true-name:AlertonDriftif:steps.plan.outputs.exit_code=='2'run:echo"::warning::Drift detected in ${{ matrix.environment }}!"