-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
CustomResource update problem #28999
Comments
An update here, just to help others with the same problem in the future. After some trial and error, I found out that the CustomResource decides if it needs updating or not only based on its props. Any change in props will trigger an update. Any change in the code backing up the Provider will not. So my solution is to pass the base64 encoding of the bash script in the props, rather than preparing it in the lambda. I guess now that I know this, the design makes sense. My only suggestion to the developers is maybe to improve the class documentation to add this information. Unless of course the devs think this is a bug and I am completely misunderstanding the current behavior. |
Did you use the custom resource framework to create your own Provider and pass to CustomResource class or you just write your own native lambda function with bash and handle the onCreate/onUpdate/onDelete yourself? Can you share a little bit about your code snippets? |
@pahud thanks for your reply. on a high level, here is what I do:
if the bash scripts are a string in the lambda code and I change them, the change is not picked up. if I pass them to the props, changes are properly detected. I just find it a bit strange that changes in the lambda code do not trigger an update. there may be a lot of things happening in boto3 that cannot easily be wrapped in a prop, and maybe on code change one wants the onEvent hook to be reexecuted. The only way to achieve this in my case would be apparently to add a timestamp to the props. |
As I didn't see your code I can't see what's going on there but generally, if you change any code lambda uses, CDK would detect that and update the lambda function 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
I have a CustomResource, implementing a Sagemaker StudioLifecycleConfig.
I use a aws_lambda.Function as a handler for the Provider.
The lambda code contains the bash scripts that define the Lifecycle, converts them to base64 and handles the creation/deletion/update of the Lifecycle using boto3 calls. Since Lifecycle are immutable, on update I delete and recreate the existing Lifecycle.
After initial deployment, I change the bash scripts defining the Lifecycle and redeploy.
Expected Behavior
When I change the bash scripts within the lambda, the desired outcome would be that the CustomResource realizes it needs to be updated and triggers the Provider with an Update event.
Current Behavior
No changes are detected.
Is this intended? What is the recommended way to update a CustomResource each time the code underlying its Provider changes?
Reproduction Steps
Can't really past code here. I hope the explanation is clear enough to at least confirm if this behavior is intended, and possibly provide guidance on how to achieve the desired outcome instead.
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.115.0
Framework Version
No response
Node.js Version
18.17.1
OS
linux
Language
Python
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: