This behavior isn't possible with CloudFormation. The reason is that referring to
$LATEST cannot guarantee a reproducible state for your stack.
Suppose you performed a successful deployment. Then, after the deployment, the latest version of your Lambda Layer changed. Later, you attempt a new deployment that fails. If this happens, CloudFormation will then attempt to revert to the previous known good state. To revert to that known state, CloudFormation needs the specific version number of the Lambda Layer. That's why the specific version number needs to be in the stack template.
Many customers overcome this limitation by including the layer itself in the stack template (via
AWS::Lambda::LayerVersion) and making a reference to it. Otherwise, you can do things like put placeholders like
$LAYER_VERSION into your CloudFormation YAML template, and substitute the value of the Lambda version into it after you upload it using an external program such as
envsubst, before updating the stack with the rendered template.
auto update AWS Lambda Application with lambda referencing layerAccepted Answerasked a year ago
Lambda container and oci image manifest typeasked 5 months ago
How do I updated a CloudWatch Synthetics Canary layer version number using the AWS CLI?asked 6 months ago
CDK NodejsFunction with Lambda Layerasked 5 months ago
How to create Lambda using AWS Serverless Application Model (SAM) without an AWS managed IAM policy?asked 5 months ago
Can Lambda automatically update layer configurations?asked 7 months ago
AWS Lambda Application with Integration and Production EnvironmentsAccepted Answerasked 9 months ago
Lambda Layer user permissionsAccepted Answerasked 8 months ago
How to create a lambda layer for a CodeStar project?asked 4 years ago
Best practices for lambda layer dependenciesasked 6 months ago