Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda SAM, specify multiple policies

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.

like image 597
tmp dev Avatar asked Feb 26 '26 08:02

tmp dev


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
like image 52
maafk Avatar answered Feb 28 '26 21:02

maafk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!