aws / aws/aws-sam-cli

Allow deploying a stack containing a function with AutoPublishAlias even when its code has not changed

Open
#3,745 1 comment 0 reactions 0 assignees View on GitHub
stage/pm-review type/feature
Dominant language
Python
Stars
6.7k
Forks
1.2k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

We have a CloudFormation stack containing multiple Lambda functions. Those functions are used in other parts of our application as lambda@edge for CloudFront distributions (defined in another stack), so we need to enable versioning on the lambdas and we have set `AutoPublishAlias: live` on all of them to achieve this goal.

Our current issue is that when we update one of the functions' code (but not all of them), the stack fails to deploy because it complains other functions already have an existing version:
> A version for this Lambda function exists ( X ). Modify the function to create a new version.

Before I updated the SAM CLI, the behavior was different: it created a new version after each stack deployment, regardless of changes. It kind of worked for us, but was also not ideal at all, because it prevented us from automating the lambda@edge stack deployment with our CD, as it would create new lambda versions with each release of our app (for the same reason, we also don't want to update every lambda's code in the stack each time we deploy it).

We only want to create a new version if the function code or configuration has changed, and manually update the version the CloudFront distributions' lambda@edge point to (using stack parameters) when needed (as lambda@edge unfortunately does not support aliases).

How can we achieve this? If the SAM CLI was not trying to create a new version when its code has not changed it would work for us, but I'm not sure that behavior is desirable/doable from your standpoint.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.