(aws-lambda): Deploying updated stack with unchanged Lambda and modified execution role fails with error: "A version for this Lambda function exists ( {n} ). Modify the function to create a new version" #14428
Labels
@aws-cdk/aws-lambda
Related to AWS Lambda
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
Hello,
With CDK 1.101.0, I'm encountering this when attempting to deploy an updated stack with an unchanged Lambda, but where I've changed the policy configuration of its execution role, e.g. with
someFunction.role.addToPrincipalPolicy()
.Somewhat related to #5334.
So in this case the Lambda resource in the CloudFormation template is identical except for the addition of an AWS::IAM::Policy's name to its
DependsOn
set.Based on the description of #6771 and a skim of the code, I'm assuming it's incorporating the function's
DependsOn
attribute in the hashing. And based on the documentation ofDependsOn
, it sounds like that should be irrelevant for the purpose of #6771, right? What do you think about omitting it from the hashing?So in plain CloudFormation it doesn't automatically create a new version in response to changes to the function code or configuration, correct? You either need to manually change something about the version configuration, like description, or wire up something to detect changes to the function yourself and do something that forces CloudFormation to create a new version, like here you're changing the logical ID.
I'm temporarily using the workaround from #5334.
Reproduction Steps
First iteration:
Second iteration:
What did you expect to happen?
Both iterations to deploy successfully, modifying the Lambda's execution role in the second one.
What actually happened?
On the second iteration, failed deployment with error message (where
{n}
is a placeholder):Environment
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: