-
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
(custom-resources): Document possibility of deletion failure when migrating from AwsCustomResource created prior to 1.92.0 #25668
Comments
Doing a little digging, I suspect this may have been introduced with this change introduced in
|
I'm not sure there's much we can do, this should have been hidden behind a feature flag. Check out this thread, is the information here able to unblock you? If you can find a way to move along with deployment while ignoring the custom resource error, your stack should still be in good shape. You just might have to manually delete whatever was initially created with your custom resource |
Not sure how I missed that thread when searching!
Yeah, I seemed to be able to get past it, I think since I didn't actually have anything in the 'on delete' of the custom resource it just sort of 'fixed itself up'; but wanted to raise it here for others who may run into the issue.
It might be overkill given CDK Either way, not really a blocker for me anymore, but for the sanity of future users upgrading in the path of 'latest Reference from other thread that may help others:
|
Sure, we can see about adding something about this to the devguide. Thanks! |
Describe the bug
I had a very old (AWS CDK
1.32.2
) custom resource deployed, I updated to the latest1.x
version of AWS CDK (on my way to2.x
) as recommended in the upgrade guide. I removed the oldAwsCustomResource
from my stack, and replaced it with a constructUserPoolDomainTarget
that uses a similar one under the hood.When I was deploying my stack, I got the following error:
Looking at the logs that back the lambda function running this
AwsCustomResource
, the following is relevant:Note that the
ResourceProperties.Create
is NOTJSON.stringify
'd in the above logs, as this was deployed by a very old version of AWS CDK.Looking at the code for the lambda function:
The handler first tries to decode the
event.ResourceProperties.*
data, yet becausedecodeCall
is expectingJSON.stringify
'd data, it crashes:To fix this,
decodeCall
should be updated to first check if the data is an object/string, and only try and decode it if it's a string. It might also make sense to add sometry
/catch
logic here so that end users get better logs about what went wrong and why (or even better, if it gracefully recovers from errors like this in future)Expected Behavior
The lambda code backing the
AwsCustomResource
would correctly handle both legacy non-JSON.strigify
'd code, as well as the modernJSON.stringify
'd version without crashing.Current Behavior
2023-05-22 18:58:44 UTC+1000 | DescribeCognitoUserPoolDomain9D8EB6B4 | DELETE_FAILED | Received response status [FAILED] from custom resource. Message returned: Unexpected token o in JSON at position 1 (RequestId: 3c59ea0a-3fdf-4aef-a0cc-a665da419f4d)
Reproduction Steps
See description in 'Describe the bug' above.
Possible Solution
See description in 'Describe the bug' above.
Additional Information/Context
See description in 'Describe the bug' above.
CDK CLI Version
1.201.0 (build 2ca8e92)
Framework Version
1.201.0
Node.js Version
v16.15.1
OS
macOS Ventura 13.3.1
Language
Typescript
Language Version
No response
Other information
See description in 'Describe the bug' above.
The text was updated successfully, but these errors were encountered: