繁体   English   中英

Cloudformation IAM政策

[英]Cloudformation IAM Policy

我很困惑如何在Cloudformation模板中包含策略以允许

下面的Cloudformation模板创建了一个角色,该角色允许执行我的Lambda函数。 现在,我需要添加一个允许API执行Lambda函数的策略。 从AWS文档中,我了解到我必须添加以下策略,但是我不清楚如何将其附加到我拥有的模板中。

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "execute-api:Invoke"
      ],
      "Resource": [
        "arn:aws:execute-api:us-east-1:*:a123456789/test/POST/mydemoresource/*"
      ]
    }
  ]
}

这是我当前的模板

  LambdaServiceRole:
        Type: AWS::IAM::Role
        Properties:
          AssumeRolePolicyDocument:
            Version: '2012-10-17'
            Statement:
            - Effect: Allow
              Principal:
                Service:
                - lambda.amazonaws.com
              Action: sts:AssumeRole
          ManagedPolicyArns:
          - "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
          Path: "/"

我相信您会希望AssumeRolePolicyDocument操作是一个列表。

LambdaServiceRole:
  Type: AWS::IAM::Role
  Properties:
    AssumeRolePolicyDocument:
      Version: '2012-10-17'
      Statement:
      - Effect: Allow
        Principal:
          Service:
          - lambda.amazonaws.com
        Action: 
          - sts:AssumeRole
    ManagedPolicyArns:
    - "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
    Path: "/"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM