代码之家  ›  专栏  ›  技术社区  ›  kkesley

基于模板的云信息访问控制

  •  0
  • kkesley  · 技术社区  · 8 年前

    我目前正在学习一门使用AWS EMR的课程。每当我想使用EMR时,我就必须启动一个.sh(我们称之为 launch.sh )基本上是启动CloudInformation模板的脚本 cf.json )有一个 template_url 变量在 发射台 把它指向S3中的JSON文件( 杰森 )使用HTTP端点。

    我有权写入和读取该bucket(而不是删除/附加acl)。我成功地创建了 杰森 我称之为 cf2.json . 但是,当我指出 发射台 到 CF2.JSON ,我收到拒绝权限错误。

    你知道这是什么原因吗?是否有关于 模板地址 在云形成中?

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

    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/*
    

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

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

    这是中的脚本 发射台

    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文件( 杰森 和; CF2.JSON 没有 public-read acl和我通过尝试从我的个人计算机复制文件来确认它,当尝试执行时返回403 s3 cp .

    1 回复  |  直到 8 年前
        1
  •  1
  •   kkesley    8 年前

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

    您可以在IAM角色中强制模板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"
                }
            }
        }]
    }