Skip to content
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): onDelete is called before onCreate is done #26139

Open
magidnadav opened this issue Jun 27, 2023 · 1 comment
Open

(custom-resources): onDelete is called before onCreate is done #26139

magidnadav opened this issue Jun 27, 2023 · 1 comment
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. bug This issue is a bug. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p1

Comments

@magidnadav
Copy link

magidnadav commented Jun 27, 2023

Describe the bug

The custom resource lambda gets called with a delete event before the create event lambda ended.

When a stack containing a custom resource failed to deploy for reasons that are not related to the custom resource.
cloud formation canceled the creation of the custom resource ("Resource creation cancelled") and then called the lambda with a delete event.
This called can happen while a different instance of the lambda performs the create flow which can cause an unstable state.

Expected Behavior

CDK will wait until the create flow is done before starting the delete flow

Current Behavior

CDK logs:

[2023-06-26T19:14:29.759Z] | 7:13:34 PM | CREATE_IN_PROGRESS | AWS::CloudFormation::CustomResource | (fixrds358createrdstableintegrationsCreateTableAndUser76462F51)

[2023-06-26T19:14:29.762Z] | 7:13:38 PM | CREATE_FAILED | AWS::CloudFormation::CustomResource | (fixrds358createrdstableintegrationsCreateTableAndUser76462F51) Resource creation cancelled

[2023-06-26T19:14:29.762Z] | 7:13:40 PM | DELETE_IN_PROGRESS | AWS::CloudFormation::CustomResource | (fixrds358createrdstableintegrationsCreateTableAndUser76462F51)

[2023-06-26T19:14:29.769Z] | 7:14:08 PM | DELETE_COMPLETE | AWS::CloudFormation::CustomResource | (fixrds358createrdstableintegrationsCreateTableAndUser76462F51)

cloud watch logs:

The create lambda invocation:
2023-06-26T19:13:38.438Z 7f69edde-d3f6-4dd1-ae40-086b4d765112 INFO { RequestType: 'Create', ...}
...
2023-06-26T12:14:07.998-07:00 | REPORT RequestId: 7f69edde-d3f6-4dd1-ae40-086b4d765112

The delete lambda invocation:
2023-06-26T12:13:44.680-07:00 | 2023-06-26T19:13:44.680Z 406167ae-a7c6-4ce1-80bd-6d9b9dc2f2ba INFO { RequestType: 'Delete', ...}
...
23-06-26T12:14:06.259-07:00 | REPORT RequestId: 406167ae-a7c6-4ce1-80bd-6d9b9dc2f2ba

Notice that the delete lambda start before the create lambda starts.

Reproduction Steps

I will try to create one soon

Possible Solution

Do not initiate the custom resource delete flow until it was created.

Additional Information/Context

No response

CDK CLI Version

2.75.0

Framework Version

No response

Node.js Version

18

OS

Ubuntu

Language

Typescript

Language Version

No response

Other information

No response

@magidnadav magidnadav added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 27, 2023
@github-actions github-actions bot added the @aws-cdk/custom-resources Related to AWS CDK Custom Resources label Jun 27, 2023
@peterwoodworth
Copy link
Contributor

This sounds like a bug with CloudFormation, I recommend reaching out on the CloudFormation Coverage Roadmap.

@peterwoodworth peterwoodworth added p1 needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. bug This issue is a bug. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p1
Projects
None yet
Development

No branches or pull requests

2 participants