Skip to main content
Technology & EngineeringDevOps Cloud73 lines

Infrastructure As Code

Provision and manage cloud infrastructure through code rather than manual configuration. Covers Terraform, Pulumi, CloudFormation, and IaC best practices. Trigger keywords: IaC, Terraform, infrastructure as code, CloudFormation, Pulumi, provisioning, state management.

Quick Summary21 lines
Infrastructure as Code treats infrastructure provisioning and configuration as a
software engineering discipline. Every server, network, database, and permission
is defined in version-controlled code that can be reviewed, tested, and reproduced
deterministically. The principle is simple: if it is not in code, it does not exist.

## Key Points

- **Declarative Definitions**: Describe the desired end state of infrastructure
- **State Management**: Maintain a state file that maps declared resources to
- **Modular Composition**: Package reusable infrastructure components as modules
- **Plan Before Apply**: Always generate and review an execution plan before
- **Drift Detection**: Periodically compare actual infrastructure state against
- **Environment Parity**: Use the same modules with different variable files to
- Store all IaC in version control alongside application code or in a dedicated
- Use remote state with locking. Local state files cause conflicts and data loss
- Never hardcode secrets in IaC files. Reference secret managers or inject at
- Tag every resource with owner, environment, project, and cost center for
- Write automated tests for infrastructure modules using tools like Terratest
- Pin provider and module versions to prevent unexpected behavior from upstream
skilldb get devops-cloud-skills/infrastructure-as-codeFull skill: 73 lines
Paste into your CLAUDE.md or agent config

Infrastructure as Code

Core Philosophy

Infrastructure as Code treats infrastructure provisioning and configuration as a software engineering discipline. Every server, network, database, and permission is defined in version-controlled code that can be reviewed, tested, and reproduced deterministically. The principle is simple: if it is not in code, it does not exist. Manual changes are the enemy of reliability, auditability, and disaster recovery.

Key Techniques

  • Declarative Definitions: Describe the desired end state of infrastructure and let the tool determine the steps to achieve it. Terraform HCL and CloudFormation YAML are declarative; scripts are imperative.
  • State Management: Maintain a state file that maps declared resources to real infrastructure. Remote state backends (S3, GCS) with locking prevent concurrent modifications and enable team collaboration.
  • Modular Composition: Package reusable infrastructure components as modules with well-defined inputs and outputs, enabling consistent patterns across teams.
  • Plan Before Apply: Always generate and review an execution plan before making changes. The plan shows exactly what will be created, modified, or destroyed.
  • Drift Detection: Periodically compare actual infrastructure state against the declared configuration to detect and remediate manual changes.
  • Environment Parity: Use the same modules with different variable files to create identical dev, staging, and production environments.

Best Practices

  • Store all IaC in version control alongside application code or in a dedicated infrastructure repository with the same review processes.
  • Use remote state with locking. Local state files cause conflicts and data loss in team environments.
  • Never hardcode secrets in IaC files. Reference secret managers or inject at apply time via environment variables.
  • Tag every resource with owner, environment, project, and cost center for visibility and cost attribution.
  • Write automated tests for infrastructure modules using tools like Terratest or kitchen-terraform.
  • Pin provider and module versions to prevent unexpected behavior from upstream updates.
  • Use workspaces or directory structures to isolate environments, never share state between production and non-production.

Common Patterns

  • Hub-and-Spoke Networking: A central networking module provisions VPCs, subnets, and peering; application modules consume network outputs as inputs.
  • GitOps for Infrastructure: Merge to main triggers automated plan and apply, with pull request plans serving as the review mechanism.
  • Layered Stacks: Separate long-lived foundational infrastructure (networking, IAM) from frequently changing application infrastructure to reduce blast radius.
  • Self-Service Modules: Provide pre-approved, parameterized modules that application teams can use without deep infrastructure knowledge.

Anti-Patterns

  • ClickOps — making infrastructure changes through cloud console UIs. These changes are untracked, unrepeatable, and invisible to the team.
  • Monolithic state files containing hundreds of resources. A single failed apply can block all infrastructure changes.
  • Copying and pasting infrastructure code instead of creating reusable modules.
  • Ignoring state file security. State contains sensitive data including resource IDs, IP addresses, and sometimes passwords.
  • Applying changes without reviewing the plan first. A single misconfiguration can destroy production databases.
  • Not implementing proper IAM for the IaC pipeline itself. The CI/CD service account that applies infrastructure changes is a high-value target.

Install this skill directly: skilldb add devops-cloud-skills

Get CLI access →

Related Skills

Monitoring Observability

Build observability systems using metrics, logs, and traces to understand system behavior and diagnose issues. Trigger keywords: monitoring, observability, metrics, logging, tracing, Prometheus, Grafana, Datadog, alerting, SLO, SLI.

DevOps Cloud71L

Security Devops

Integrate security practices into DevOps workflows and CI/CD pipelines. Covers shift-left security, vulnerability scanning, and secure development lifecycle. Trigger keywords: DevSecOps, security automation, vulnerability scanning, SAST, DAST, supply chain security, shift-left.

DevOps Cloud147L

Service Mesh

Implement service mesh infrastructure for managing microservice communication, observability, and security. Trigger keywords: service mesh, Istio, Linkerd, Envoy, sidecar proxy, mTLS, traffic management, circuit breaker.

DevOps Cloud153L

Web Infrastructure Basics

Understand DNS, domain management, CDNs, SSL/TLS, load balancing, and web hosting fundamentals. Use this skill when the user asks about setting up a domain, configuring DNS records, understanding how websites are served, choosing hosting, setting up HTTPS, or troubleshooting domain and DNS issues.

DevOps Cloud111L

CI CD Pipelines

Design and maintain continuous integration and continuous delivery pipelines that automate build, test, and deployment workflows. Trigger keywords: CI/CD, pipeline, GitHub Actions, Jenkins, GitLab CI, build automation, deployment pipeline.

DevOps Cloud143L

Cloud Architecture

Design scalable, resilient, and cost-effective systems on cloud platforms like AWS, GCP, and Azure. Trigger keywords: cloud architecture, AWS, GCP, Azure, well-architected, multi-region, high availability, cloud-native.

DevOps Cloud72L