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:
!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"
!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!