gpt4 book ai didi

aws-cloudformation - 基于template_url的Cloudformation访问控制

转载 作者:行者123 更新时间:2023-12-03 07:36:51 25 4
gpt4 key购买 nike

我目前正在注册一门使用 AWS EMR 的类(class)。每次我想使用 EMR 时,我都必须启动一个 .sh (我们称之为 launch.sh )脚本,该脚本基本上是启动一个 cloudformation 模板(假设它是 cf.json )。 template_url 中有一个 launch.sh 变量,它通过 http 端点将其定向到 s3 ( cf.json ) 中的 json 文件。

我有权写入和读取该存储桶(不是删除/附加 acl)。我成功创建了 cf.json 的副本,并将其称为 cf2.json 。但是,当我将 launch.sh 指向 cf2.json 时,出现权限被拒绝错误。

你知道是什么原因造成的吗? cloudformation中有关于template_url的权限控制吗?

这是我收到的错误。我屏蔽了日志中的所有详细信息以防止隐私问题。

An error occurred (AccessDenied) when calling the CreateStack operation: User:
arn:aws:sts::12345678:assumed-role/CrossStack-IamRole-
ABCDEFGH/i-0123456 is not authorized to perform:
cloudformation:CreateStack on resource: arn:aws:cloudformation:us-east-
1:12345678:stack/student-emr/*

但是,当我使用原始网址时,我收到了一条成功消息:

Creating EMR Cluster. This will take about 15 minutes...
{
"StackId": "arn:aws:cloudformation:us-east-1:12345678:stack/student-emr/some-hash-id"
}

这是launch.sh中的脚本

aws cloudformation create-stack --region $emr_region --stack-name $stackname \
--template-url $template_url \
--parameters ParameterKey=Owner,ParameterValue=$student_id \
--role-arn $cf_role_arn

我更改了 $template_url 变量的值

注意

两个 .json 文件( cf.jsoncf2.json )都没有 public-read ACL,我通过尝试从我的个人计算机复制文件来确认这一点,在尝试执行 s3 cp 时返回 403 。

最佳答案

我在 AWS 文档中找到了它 https://aws.amazon.com/blogs/devops/aws-cloudformation-security-best-practices/

您可以在 IAM 角色中强制执行 template_url

{
"Version":"2012-10-17",
"Statement":[{
"Effect": "Deny",
"Action": [
"cloudformation:CreateStack",
“cloudformation:UpdateStack”
],
"Resource": "*",
"Condition": {
"StringNotEquals": {
"cloudformation:TemplateURL": [
"https://s3.amazonaws.com/cloudformation-templates-us-east-1/IAM_Users_Groups_and_Policies.template"
]
}
}
},
{
"Effect": "Deny",
"Action": [
"cloudformation:CreateStack",
"cloudformation:UpdateStack"
],
"Resource": "*",
"Condition": {
"Null": {
"cloudformation:TemplateURL": "true"
}
}
}]
}

关于aws-cloudformation - 基于template_url的Cloudformation访问控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52250423/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com