SAM cloudformation attach layer to lambda

From here

Key takeaways

Give your lambda permission to your layer to GetLayerVersion

Watch the layer version!

Also, Cloudformation needs permissions to deal with layers (second code block)

  Type: AWS::Serverless::Function
    Handler: index.handler
    Runtime: python3.8
    FunctionName: 'lambda-with-layer'
    Description: 'lambda with layer'
    CodeUri: ./
      - Statement:
        - Effect: "Allow" 
            - 'lambda:GetLayerVersion' 
            - 'arn:aws:lambda:*:1234567890:layer:*:*'
      - arn:aws:lambda:us-east-2:1234567890:layer:layer1:16
  "Version": "2012-10-17",
  "Statement": [
      "Sid": "VisualEditor0",
      "Effect": "Allow",
      "Action": [
      "Resource": "*"

So after some experimenting, from what I can tell a layer would not have any security by default

View at

Also, my cloudformation policy already had “lambda:*” so it was able to create the layers as is.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s