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
Sharing Lambda layers across stack fails with error: Export EXPORT_NAME cannot be updated as it is in use by STACK_1, STACK_N #549
Comments
Hey @pabacham, do you get this error when you try to deploy after changing the layer? And can you share the stack export values from stack 1? |
а) props.api.addLayers method could potentially help me |
@pabacham, when you are sharing a layer across stack, I think the layer's ARN is automatically added as a stack export. If you go to your CFN console, find stack 1, and look at its export values, you should see it there. Let's just confirm that is the issue. |
@fwang Correct. it is there https://monosnap.com/file/ZpghS66KJhRf94xBGtA0tcx9U3WZxF |
Thanks @pabacham, does the output value for the Prisma layer end with a version number? |
Stack 1 Let me know if you mean smth other than that |
Hey @pabacham, here's what I found. What is the issue?The Lambda layer is created in stack 1 and shared in stack 2. When you share a layer across stacks, CDK creates a stack export with the layer's ARN in stack 1. And everytime the layer changes (ie. when you run codegen), the layer's ARN changes (ie. the ARN always ends with a number). However, CloudFormation does not allow updating exported values. You can read more about this CDK issue here - aws/aws-cdk#1972 How are we going to fix it?Like mentioned in the above thread, when SST detects a Lambda layer is shared across stacks, it will create an SSM parameter in stack 1 with the layer's ARN. And stack 2 will reference the SSM value, instead of the ARN directly. I'm working on a fix for this rn. |
@pabacham Fixed in v0.35.1. Give it a try! |
@fwang Does this fix only use SSM when adding layers to each function individually? I was using addDefaultFunctionLayers and noticed it defaulted back to using stack exports. It would be great if we could use addDefaultFunctionLayers and not have the dependency issue. |
Stack1 failed: Export Stack1:ExportsOutputRefPrismaLayer958161C6A54DA9DC cannot be updated as it is in use by Stack2 and Stack3
Currently, I can remove Stack2 and Stack3 manually and then update the App, is there another way how to fix the error?
The text was updated successfully, but these errors were encountered: