如何通过 cfn 模板中的策略控制访问?

问题描述

我有一个策略,定义为下面的 cloudformation 模板。我希望能够描述哪些 aws 资源,它们可以通过 cfn 模板创建。我怎么做?我在下面附上了一个示例?

Type: 'AWS::IAM::Policy'
Properties:
  PolicyName: CFNUsers
  PolicyDocument:
    Version: "2012-10-17"
    Statement:
      - Effect: Allow
        Action:
          - 'cloudformation:Describe*'
          - 'cloudformation:List*'
          - 'cloudformation:Get*'
        Resource: '*'

解决方法

您的政策包含三个操作:

          - 'cloudformation:Describe*'
          - 'cloudformation:List*'
          - 'cloudformation:Get*'

这些操作可以在所有 (*) CloudFormation (CFN) 堆栈上执行,而不是“任何 IAM 角色、用户或其他 aws 资源”。这是因为使用这三个操作只能对 CFN 堆栈进行操作。

AWS::IAM::Policymanaged IAM policy。此类策略必须攻击 IAM 用户、角色或组。通过这种方式,您可以将在 CFN 堆栈上执行三个操作的权限授予您要将策略附加到的人/物。