【发布时间】:2019-12-12 01:45:31
【问题描述】:
背景:
使用跨账户角色someaccountrole,我可以访问aws 账户xyz。
案例 1
要在帐户xyz 中创建堆栈,我们通过控制台上传 Cloudformation 文件。
在Events 选项卡中创建堆栈时,我们看到了第一个事件,如下所示:
案例 2
我们在xyz 帐户中创建EC2 实例。
使用sam deploy,其中sam deploy 是aws cloudformation deploy 的包装器,我们从EC2 运行以下命令来创建堆栈:
aws cloudformation deploy --template-file cfntemplate.yml --stack-name somestack-test --region us-east-1
在堆栈创建过程中,我们看到创建了类似的事件(如下所示):
在案例 2 中,用户是:arn:aws:sts::${AccountId}:assumed-role/Autodeploy/i-0000000cc4,我们在其中创建了 Autodeploy 角色并分配给 EC2。该用户在堆栈创建完成后消失。
但在case 2中,user(i-0000000cc4) 需要权限才能执行以下操作,这与case 1不同:
{
"Action": [
"cloudformation:CreateStack",
"cloudformation:CreateChangeSet",
"cloudformation:CreateUploadBucket",
"cloudformation:ExecuteChangeSet",
"cloudformation:DeleteStack",
"cloudformation:Describe*",
"cloudformation:UpdateStack"
],
"Resource": [
"arn:aws:cloudformation:us-east-1:${AccountId}:stack/somestack*”
],
"Effect": "Allow"
}
否则,Events 选项卡会在情况 2 中给出以下错误:
User: arn:aws:sts::${AccountId}:assumed-role/Autodeploy/i-0000000cc4
is not authorized to perform: cloudformation:CreateChangeSet on resource:
arn:aws:cloudformation:us-east-1:${AccountId}:stack/somestack-test
1) 在情况 1 中,权限为 someaccountrole 以创建堆栈。但是在案例 2 中,为什么通过 AWS CLI 创建堆栈需要堆栈创建权限?
2)如何将内联策略(短期)分配给此类临时会话资源(i-0000000cc4)而不是 EC2??
【问题讨论】:
-
我无法在 Internet 上找到有关 Autodeploy 角色的任何信息。有人知道它是在哪里创建的吗?
标签: amazon-web-services security amazon-cloudformation amazon-iam aws-sam