Infrastructure as Code (IaC) 与 CI/CD 集成,以自动化不仅是应用部署,还包括基础设施的配置和管理 — 通过管道应用基础设施更改,就像代码一样。这为基础设施带来了一致性、自动化和版本控制。
IaC 在 CI/CD 管道中
Infrastructure (servers, networks, databases) defined as CODE (Terraform, CloudFormation,
etc.) and managed THROUGH CI/CD pipelines:
→ infrastructure changes go through the SAME workflow as app code (PR → review → apply)
→ the pipeline runs the IaC tool to provision/update infrastructure automatically
→ infrastructure is version-controlled, reviewed, and applied consistently
典型的 IaC 管道
1. Infrastructure code changed (e.g. Terraform files) → push/PR
2. PLAN → the pipeline runs `terraform plan` → shows WHAT will change (review the diff)
3. REVIEW → team reviews the planned changes (PR) — catch mistakes before applying
4. APPLY → on merge, the pipeline runs `terraform apply` → makes the changes
→ Infrastructure changes are automated, reviewed, and auditable (like code changes).
