Amazon CloudFormation Git sync 先决条件 - Amazon CloudFormation
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

Amazon CloudFormation Git sync 先决条件

Git sync 的先决条件如下:

Git 存储库

Git sync 支持 GitHubGitHub EnterpriseGitLabBitbucket 存储库。存储库可以是公有的,也可以是私有的。您可以通过连接控制台将 Git 存储库连接到 CloudFormation。

CloudFormation 模板

必须将 CloudFormation 模板文件签入您打算使用 Git sync 连接的存储库和分支。此模板由堆栈部署文件引用。

IAM 角色

Git sync 需要身份和访问管理(IAM)角色。您可以选择在配置 Git sync 时为堆栈创建 IAM 角色,也可以提供现有角色。

注意

自动生成的 IAM 角色仅将权限应用于为其生成角色的堆栈。要重复使用自动生成的 IAM 角色,必须编辑新堆栈的角色。

所需的权限

为 Git sync 提供的 IAM 角色需要以下权限:

注意

上述所需权限会自动添加到 Git sync 生成的 IAM 角色中。

以下示例 IAM 角色包括 Git sync 的必备权限。

{ "Version": "2012-10-17", "Statement": [ { "Sid": "SyncToCloudFormation", "Effect": "Allow", "Action": [ "cloudformation:CreateChangeSet", "cloudformation:DeleteChangeSet", "cloudformation:DescribeChangeSet", "cloudformation:DescribeStackEvents", "cloudformation:DescribeStacks", "cloudformation:ExecuteChangeSet", "cloudformation:GetTemplate", "cloudformation:ListChangeSets", "cloudformation:ListStacks", "cloudformation:ValidateTemplate" ], "Resource": "*" }, { "Sid": "PolicyForManagedRules", "Effect": "Allow", "Action": [ "events:PutRule", "events:PutTargets" ], "Resource": "*", "Condition": { "StringEquals": { "events:ManagedBy": ["cloudformation.sync.codeconnections.amazonaws.com"] } } }, { "Sid": "PolicyForDescribingRule", "Effect": "Allow", "Action": "events:DescribeRule", "Resource": "*" } ] }

信任策略

Git sync 需要以下信任策略才能连接到 Git 存储库:

{ "Version": "2012-10-17", "Statement": [ { "Sid": "CfnGitSyncTrustPolicy", "Effect": "Allow", "Principal": { "Service": "cloudformation.sync.codeconnections.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }