Sync: add infrastructure as code notes

This commit is contained in:
2026-04-24 19:58:02 +08:00
parent cc23df1883
commit e4f6f463cb
29 changed files with 2344 additions and 155 deletions

View File

@@ -102,6 +102,36 @@ Agentic AI 在 Terraform 工作流中扮演审查者角色:
> acl = "private" # Block public access
> ```
## State File Management
Terraform 通过**状态文件 (state file)** 将声明式配置中定义的**期望状态**与云环境的**实际资源状态**进行绑定。关键特性:
- **状态锁定**:防止并发执行导致状态不一致
- **远程状态**:企业级场景需将状态文件存储在 S3+ DynamoDB 锁)等远程后端,支持团队协作
- **差异对比**`terraform plan` 预览实际变更内容再执行,是 Terraform 的核心优势
**来源**: [[ctp-topic-48-terraform-vs-terragrunt]]
## Terragrunt Wrapper
Terragrunt 是 Terraform 的轻量封装,继承所有 Terraform 命令HCL 语法完全兼容)。两者关系:
- `terragrunt plan` = `terraform plan`
- Terragrunt 通过 `remote_state``include` 块实现跨环境配置的 DRY 管理
**来源**: [[ctp-topic-48-terraform-vs-terragrunt]]
## Ecosystem Tools
| 工具 | 类型 | 用途 |
|------|------|------|
| [[Terragrunt]] | 封装 | 多环境 DRY 配置 |
| [[Atlantis]] | CI/CD | Git PR 驱动的 plan/apply |
| Terraform Enterprise | 平台 | 企业 CI + workspaces |
| [[Gruntwork]] | 模块库 | 预建可复用 IaC 模块 |
| Terratest | 测试 | IaC 集成测试Golang |
| tfsec | 安全 | Terraform 静态安全分析 |
**来源**: [[ctp-topic-48-terraform-vs-terragrunt]], [[ctp-topic-56-automated-infrastructure-testing]]
## Related Concepts
- [[Infrastructure-as-Code]] — Terraform 是 IaC 的实现工具