-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(EvaluateExpression): The logical id of lambda created by EvaluateExpression changed after nodejs upgrade. #29212
Comments
Yes I can confirm it does change when updating the runtime. This could be related to #28251. Making it a p1. |
I don't think this is related to #28251. To me it appears that this is the intended behavior. We have an object |
Thanks colifran, I understand this might be the intended behavior since we want to have different lambda created for different nodejs version. Currently, there is no way that I realize that could upgrade the nodejs version without updating the logical id of lambda. So I think team could give a workaround here by supporting |
From my test, simply updating the runtime would not change the lambda.Function logicalId. For example, change the runtime from new lambda.Function(this, 'Func', {
code: lambda.Code.fromInline('mock'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_16_X,
}); But changing the runtime for const task = new tasks.EvaluateExpression(this, 'Task', {
expression: '$.a + $.b',
runtime: lambda.Runtime.NODEJS_16_X,
}); I am guessing it's EvalNodejsSingletonFunction that returns new resources. Wondering it might because EvalNodejsSingletonFunction is actually a SingletonFunction which always ensureLambda based on given props and generate different constructName here, hence generating a new lambda.Function with different id from here. I guess it's by design how SingletonFunction works when we pass a new uuid, CDK would always create a new lambda.Function by replacing the existing one and it's how it works now. @weididai What is the impact if the lambda.Function would be replaced with a new logicalId? Can you share more about that? |
The logical id of the lambda created by EvaluateExpression is changed during a long running step function. Thus the step function fails as it tries to invoke the old lambda but the old lambda was already destroyed. |
@weididai Thank you for your report I think we should figure out a way to avoid that as updating a SingletonFunction would always change the logicalId. |
Hi @weididai Consider this sample: export class DummyStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
const expression = new tasks.EvaluateExpression(this, 'Task', {
expression: '$.a + $.b',
runtime: lambda.Runtime.NODEJS_16_X
});
this.overrideLambdaLogicalId('Evalda2d1181604e4a4586941a6abd7fe42dF371675D')
}
private overrideLambdaLogicalId(logicalId: string) {
this.node.findAll().filter((construct) =>
construct.node.id.startsWith('Eval') && (construct.node.defaultChild instanceof lambda.CfnFunction))
.forEach(x => {
(x.node.defaultChild as lambda.CfnFunction).overrideLogicalId(logicalId);
})
}
} If you change the Let me know if it works for you. |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Describe the bug
We recently encountered a issue that the logical id of lambda created by
EvaluateExpression
changed after nodejs upgrade. This resulted in a new lambda got created and the old lambda got deleted which caused some impact. Upon some investigation, we discovered that is because the logical id of lambda created byEvaluateExpression
is determined by nodejs version -- https://github.com/aws/aws-cdk/blob/v2.120.0/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/evaluate-expression.ts#L114. Is there a workaround here to do a nodejs upgrade without changing the logical id of the lambda.We already tried using the
overrideLogicalId
but it seems theoverrideLogicalId
does not support for lambda created byEvaluateExpression
Expected Behavior
The logical id of lambda created by
EvaluateExpression
should not change after nodejs upgrade.Current Behavior
The logical id of lambda created by
EvaluateExpression
is changed after nodejs upgrade.Reproduction Steps
EvaluateExpression
and check the logical id of the lambda generated.Possible Solution
overrideLogicalId
of the lambda created byEvaluateExpression
EvaluateExpression
have different nodejs version under the same path.Additional Information/Context
No response
CDK CLI Version
2.120.0
Framework Version
No response
Node.js Version
14.x
OS
linux
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: