【问题标题】:Is there anyway to determine what IAM permissions I actually need for a CloudFormation template?无论如何确定 CloudFormation 模板实际需要哪些 IAM 权限?
【发布时间】:2019-01-06 20:08:23
【问题描述】:

只是想知道确定我应该为 CloudFormation 模板授予哪些权限的最佳做法是什么?

在尝试提供所需的最低权限一段时间后,我发现这确实非常耗时且容易出错。我注意到,根据我的堆栈状态,真正的新、一些更新和删除,我需要不同的权限。

我想,应该有可能有一些解析器给定 CloudFormation 模板可以确定它所需的最小权限集?

也许我可以让ec2:* 访问标记为Cost Center: My Project Name 的资源?这个可以吗?但是我想知道当我更改项目名称时会发生什么?

或者,假设 CloudFormation 部分通常仅在 CodeCommit/Github/CodePipeline 之外执行,并且它不是可能公开/易于破解的东西,是否可以假设可以提供 ec2:* 访问权限? --- 虽然这对我来说听起来像是一个有缺陷的陈述......

【问题讨论】:

  • 我在一次会议上与多位 AWS 工程师讨论了这个问题,他们的回答是:“不是真的”。最好的方法是什么都不分配,看看它会抛出什么错误。
  • @Exelian omg ... 已经这样做了将近 2 天了... 我什至没有授予所有访问权限... 我只是通读了列表并尝试只选择那些我认为我需要......即使那样我也花了这么长时间......

标签: amazon-web-services amazon-cloudformation amazon-iam


【解决方案1】:

短期内可以使用aws-leastprivilege。 But it doesn't support every resource type.

从长远来看:as mentioned in this 2019 re:invent talk,CloudFormation 正致力于开源并将其大部分资源类型迁移到新的公共resource schema。这样做的好处之一是您将能够看到执行每个操作所需的权限。

例如对于AWS::ImageBuilder::Image,架构表示

    "handlers": {
        "create": {
            "permissions": [
                "iam:GetRole",
                "imagebuilder:GetImageRecipe",
                "imagebuilder:GetInfrastructureConfiguration",
                "imagebuilder:GetDistributionConfiguration",
                "imagebuilder:GetImage",
                "imagebuilder:CreateImage",
                "imagebuilder:TagResource"
            ]
        },
        "read": {
            "permissions": [
                "imagebuilder:GetImage"
            ]
        },
        "delete": {
            "permissions": [
                "imagebuilder:GetImage",
                "imagebuilder:DeleteImage",
                "imagebuilder:UnTagResource"
            ]
        },
        "list": {
            "permissions": [
                "imagebuilder:ListImages"
            ]
        }
    }

【讨论】:

    猜你喜欢
    • 2018-03-04
    • 2019-11-28
    • 2012-10-09
    • 2017-08-08
    • 2019-09-24
    • 1970-01-01
    • 2020-01-18
    • 1970-01-01
    • 2014-08-28
    相关资源
    最近更新 更多