Files
nexus/wiki/concepts/Cross-account-Modules.md
2026-04-20 07:08:14 +08:00

30 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
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]] — 执行单元