- Newest
- Most votes
- Most comments
Yes, there are ways to update Lambda layers without deploying the full stack, although it's not directly supported through AWS SAM or CloudFormation without some additional steps.
Here are a few approaches you can consider:
-
Use the AWS Lambda Console: You can manually update the layer version for specific functions using the Lambda console. Navigate to the Layers page, select the layer you want to update, choose the functions you want to modify, and update them to use the new layer version.
-
AWS CLI: You can use the AWS CLI to publish a new layer version and then update the functions to use this new version. This would involve using the
publish-layer-version
command to create a new layer version, followed byupdate-function-configuration
to update the functions to use the new layer. -
Custom Resource in CloudFormation: You could implement a custom resource in your CloudFormation template that checks for content changes in your layer and triggers updates accordingly. This would allow you to update just the layer without redeploying the entire stack.
-
Separate Stack for Layers: Consider creating a separate CloudFormation stack just for your layers. This way, you can update and deploy only the layer stack without touching the main application stack.
-
Use Parameters: In your CloudFormation template, use a parameter to represent the layer version. When you need to update the layer, you can update this parameter value, which will trigger an update of the layer without necessarily redeploying the entire stack.
While these methods provide ways to update layers more selectively, it's important to note that AWS SAM and CloudFormation are designed to manage the entire application stack as a unit. For more granular control over individual components like layers, you might need to combine these tools with custom scripts or workflows.
Sources
Adding layers to functions - AWS Lambda
Lambda Layer not changing when taken from S3 in cf template | AWS re:Post
Yes, create new Lambda layer
aws lambda publish-layer-version \
--layer-name new-layer \
--description "New Lambda Layer" \
--zip-file fileb://layer.zip \
--compatible-runtimes python3.10 python3.11
This will give you the lambda layer ARN. Then update the lambda function
aws lambda update-function-configuration \
--function-name my-demo-function \
--layers arn:aws:lambda:ap-southeast-2:123456123456:layer:new-layer:4 ## obtained from previous section
Relevant content
- asked a year ago
- asked 10 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago