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

Phsyical ID as argument to delete? #53

Open
mdavis-xyz opened this issue Sep 20, 2021 · 6 comments
Open

Phsyical ID as argument to delete? #53

mdavis-xyz opened this issue Sep 20, 2021 · 6 comments

Comments

@mdavis-xyz
Copy link

I'm trying to create a custom resource for a physical resource which has a non-deterministic ID/ARN.

i.e. when I receive the delete call, I cannot figure out which resource to delete based on the properties of the resource. I instead need to get whatever value was returned by create.

I'm hoping this value is somewhere inside the event. If so, can you please document where in the event it is?

@mdavis-xyz
Copy link
Author

Is it event['PhysicalResourceId']?

@iainelder
Copy link

when I receive the delete call, I cannot figure out which resource to delete based on the properties of the resource. I instead need to get whatever value was returned by create. [...] Is it event['PhysicalResourceId']?

In general the response to the create request will contain a PhysicalResourceId, either set by you or generated by the helper.

CloudFormation passes the same PhysicalResourceId in the delete request.

If your custom resource has to clean up something that that was created during handling of the create request, then it's your responsibility to set the PhysicalResourceId such that it unambiguously identifies what needs to be cleaned up.

The best documentation I've found is CloudFormation's own documentation of the request and response formats. There you'll see the PhysicalResourceId documented.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requesttypes.html

@mdavis-xyz
Copy link
Author

Ok thanks, that clarifies it.

I think that link should be put in the docs somewhere. I'll write a PR for that.

@blueskycorner
Copy link

Hi,
In my create function I'm creating an AD connector. Its Id it generated by aws SDK. I use the poll_create function to check when the AD connector is ready. I return the id to have it as PhysicalResourceId. So far so good.

My problem is when AD connector creation fails. I detect it in the poll_create function but I have to raise an error to indicate there was a problem. Doing so I'm not able to return the AD connector id .... The PhysicalResourceId is generated and when my delete function is fired it is not able to delete the AD connector.

Am I missing something?

Best regards,

@iainelder
Copy link

iainelder commented Feb 14, 2022

Hi @blueskycorner , you can set the helper.PhysicalResourceId property before you raise an error.

I left an example on another issue when I discovered it: #7 (comment) Does it help you?

I haven't tried to use polling yet, so it's just a guess that it works the same way.

If you need more help I'd suggest you open a new issue with more details so that the repo maintainers may help.

@blueskycorner
Copy link

@iainelder Thank you so much for your quick reply. It works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants