Not able to add policies in SAM template

前端 未结 3 964
猫巷女王i
猫巷女王i 2021-02-20 13:46

I am working on SAM template for publishing my Application in AWS Serverless repository. But when I try to add policies for my lambda it shows me error: Invalid Serverless Appli

3条回答
  •  攒了一身酷
    2021-02-20 14:12

    As of today (2018-10-09), SAM template already supports inline policy document.

    Here is an example:-

    Resources:
      SomeFunction:
        Type: AWS::Serverless::Function
        Properties:
          Handler: index.handler
          Runtime: nodejs8.10
          Policies:
          - Statement:
            - Sid: SSMDescribeParametersPolicy
              Effect: Allow
              Action:
              - ssm:DescribeParameters
              Resource: '*'
            - Sid: SSMGetParameterPolicy
              Effect: Allow
              Action:
              - ssm:GetParameters
              - ssm:GetParameter
              Resource: '*'
    

    References:

    1. AWS::Serverless::Function's Policies property on AWS SAM Specification
    2. Related issue on GitHub

提交回复
热议问题