2

I have a Cloudformation template that currently looks roughly like the following.

Resources: MyLayer: Type: AWS::Lambda::LayerVersion Properties: CompatibleRuntimes: - nodejs12.x - nodejs10.x Content: ../layers/nodejs/ LayerName: myLayer ### etc... MyLambda: Type: AWS::Lambda::Function DependsOn: MyLayer Properties: Code: lambdas/my-lambda.js Description: A lambda that makes use of MyLayer FunctionName: myLambda Handler: my-lambda.handler Layers: !Ref CommonLayer ### etc... 

The core idea here is I want to create a new LayerVersion and have the Lambda update to this latest LayerVersion on every deployment. I am having trouble inserting MyLayer's Arn into MyLambda's Layer property. Here is what I have tried:

  1. !Ref CommonLayer which I saw returns the Arn based on this CloudFormation Cheatsheet. I get a failure when creating the stack at the creation of MyLambda (output shows MyLayer has been successfully created) saying: "Value of property Layers must be of type List of String"

  2. !GetAtt CommonLayer.Arn however this function is just not supported for Layers/ the return value does not have an Arn field.

Is this a YAML syntax type problem or is my goal of creating a Layer and then a Lambda that depends on said Layer not possible in one Cloudformation template? Thanks!

1 Answer 1

0

Value of property Layers must be of type List of String

Layers must be a List. You’ll have to replace:

 MyLambda: Properties: Layers: !Ref CommonLayer 

With this:

 MyLambda: Properties: Layers: - !Ref CommonLayer 

Hope that helps :)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.