Auto-sync: 2026-04-20 07:08
This commit is contained in:
30
wiki/concepts/Cross-account-Modules.md
Normal file
30
wiki/concepts/Cross-account-Modules.md
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: "Cross-account Modules"
|
||||
type: concept
|
||||
tags: [terraform, multi-account, security]
|
||||
last_updated: 2026-04-20
|
||||
---
|
||||
|
||||
## Definition
|
||||
- Cross-account Modules 指在一个 Terraform 模块中通过配置多个 Provider,实现在多个 AWS 账号中同时创建或管理资源的功能
|
||||
|
||||
## Why Needed
|
||||
- 复杂云架构经常需要在一个模块内跨多个账号创建资源(例如在 InfoBlocks 账号配置 DNS,同时在 Workload 账号部署应用)
|
||||
|
||||
## Security Concern
|
||||
- 直接赋予账号间互访权限存在巨大的安全风险,如某一账号被攻破可能波及全局(Blast Radius 问题)
|
||||
|
||||
## Solution
|
||||
- 基于 Shared Account 的中心化部署方案,通过 Assume Role 方式访问目标账号,避免直接授予互访权限
|
||||
|
||||
## Implementation Components
|
||||
- cross-account.json:标记文件,告知 Jenkins 该模块需要调用跨账号部署逻辑
|
||||
- ECS Deploy Runner:运行在 ECS 上的 Docker 容器,负责执行 Terraform plan 和 apply
|
||||
- TF state bucket accessor:专门定义的 IAM 角色,仅允许部署工具访问状态文件
|
||||
- Cross-account ECS deploy runner role:部署在目标账号中的角色,允许 Shared Account 的执行器切换角色获取权限
|
||||
|
||||
## Connections
|
||||
- [[Terraform]] — 基础工具
|
||||
- [[Terragrunt]] — 配置管理
|
||||
- [[Shared Account]] — 信任源
|
||||
- [[ECS Deploy Runner]] — 执行单元
|
||||
Reference in New Issue
Block a user