AWS Lambda SAM, specify multiple policies

Viewed 1281

I have the following AWS SAM file (showing extract) for a lambda function. The problem is that I'm trying to specify multiple policies and this does not work, I get an error

Resources:
  Get:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: fnStores
      Handler: handler.get
      Runtime: nodejs6.10
      Policies: 
        -AmazonDynamoDBReadOnlyAccess
        -AmazonS3ReadOnlyAccess

This is the error I get

"ARN -AmazonDynamoDBReadOnlyAccess -AmazonS3ReadOnlyAccess is not valid.

On a side note, is it possible to create a custom policy that combines the above two and then use that? If so please provide an example.

1 Answers

The YAML list isn't valid. Need a space between - and the Policy names

Try

Resources:
  Get:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: fnStores
      Handler: handler.get
      Runtime: nodejs6.10
      Policies: 
        - AmazonDynamoDBReadOnlyAccess
        - AmazonS3ReadOnlyAccess
Related