Files
nexus/wiki/concepts/Infrastructure-as-Code.md
2026-04-26 20:02:45 +08:00

2.6 KiB
Raw Blame History

title, type, tags, sources, last_updated
title type tags sources last_updated
Infrastructure as Code concept
DevOps
AWS
Terraform
Automation
ctp-topic-3-deploy-and-maintain-infrastructure
ctp-topic-9-ci-cd-with-gruntwork
ctp-topic-48-terraform-vs-terragrunt
ctp-topic-32-using-atlantis-cicd-for-infrastructure-deployments
ctp-topic-33-an-introduction-to-gitops
ctp-topic-56-automated-infrastructure-testing
learning-sessions-ecs-deployment-using-iac-20230808-183322-meeting-recording
cloud-operating-model-key-strategies-and-best-practices
2026-05-05

Infrastructure as Code

Definition

基础设施即代码Infrastructure as Code, IaC是一种通过机器可读的定义文件而非物理硬件配置或交互式配置工具管理和配置计算基础设施的方法。

Core Principles

  • 声明式配置:描述期望的最终状态,而非执行的具体步骤
  • 版本控制:所有基础设施定义文件存储在 Git 中
  • 幂等性:多次执行产生相同结果
  • 可重复性:同一模板可在不同环境快速部署
  • 自动化:与 CI/CD 流水线集成

Key Tools

  • TerraformHashiCorp 出品,云厂商无关的 IaC 工具,通过状态文件管理资源
  • TerragruntTerraform 轻量封装,贯彻 DRY 原则
  • AWS CloudFormationAWS 原生 IaC 服务JSON/YAML 模板
  • Pulumi:编程语言驱动的 IaC 平台
  • Ansible:配置管理和应用部署工具

Terraform Ecosystem

  • Gruntwork:预建 Terraform 模块库,生产级参考架构
  • AtlantisGit 集成 Terraform 部署PR 评论式协作
  • TerratestTerraform 代码的 Go 测试框架
  • tfsecTerraform 静态安全分析工具
  • TFLintTerraform 代码规范检查

IaC in CTP Context

CTPCloud Transformation Programme使用 Terraform/Terragrunt 构建 AWS Landing Zone