Infrastructure as Code (IaC)
Define infrastructure in versioned code.
Install 安装
curl -sSL https://updating.cc/skills/devops/infrastructure-as-code/SKILL.md -o ~/.agents/skills/devops__infrastructure-as-code/SKILL.mdSKILL.md Preview 技能内容预览
---
name: Infrastructure as Code (IaC)
description: Define infrastructure in versioned code.
---
# Infrastructure as Code
IaC treats infrastructure like application code: versioned, reviewed, repeatable. Manual click-ops is unreviewable, unreproducible, and unrecoverable when the person who did it leaves.
## Principles
- **Declarative over imperative.** Describe the desired state ("3 instances behind a load balancer"); the tool reconciles reality to match. Imperative scripts drift.
- **Versioned and reviewed.** Infra changes go through PRs like code. The history is your audit trail and your rollback.
- **Idempotent.** Running the same config twice yields the same result, not two copies. Safe to re-apply.
- **State separated from config.** Track what's actually deployed separately from what's declared; diff them to detect drift.
## Use
- A new environment is `terraform apply` with different variables — minutes, not weeks.
- Disaster recovery means re-applying the code, not reconstructing a click history nobody recorded.