How do you use Pulumi to destroy resources like Cl...
# general
How do you use Pulumi to destroy resources like CloudFront distributions (which need to be disabled before they can be destroyed) that require other operations to be preformed before they can be removed. I cannot seem to find a way to add custom destroy logic to a Pulumi stack. Does anyone have experience doing this? (Stackoverflow question here:
There is not yet a first-class feature for adding custom logic to resource deletion. The closest thing that you can do today is using Dynamic Providers. These allow you to write a new kind of resource whose Create, Read, Update and Delete operations are defined in JavaScript, and so can put your custom logic in the Delete operation of this resource, and then make your CloudFront resource dependent on this custom resource so that it must be deleted before attempting to delete the CoudFront distribution. We have limited documentation on these Dynamic Providers currently (I will be adding some docs soon!) - but you can see one example of this here: That said, I have not seen issues destroying CloudFront distributions in the past. What specifically are the "other operations" you need to do prior to deleting it in your case?
@fierce-carpet-95079 can you post the specific error as well? The error had to do with not being able to destroy an enabled cloudfront distro.
So sorry! We were acutally able to track down the issue to a statefile/reality miss-match. Sorry for the false alarm. We are though experiencing an issue with the destruction sequencing. Such as the bucket destroy fails because the bucket objects are not deleted yet. A second run of the destroy removes all the failed resources but I was wondering how we needed to declare it to get proper sequencing.