https://pulumi.com logo
#general
Title
# general
f

fierce-carpet-95079

04/17/2019, 3:13 PM
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: https://stackoverflow.com/questions/55730860/custom-pulumi-destroy-logic)
w

white-balloon-205

04/17/2019, 3:36 PM
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: https://github.com/pulumi/examples/blob/733235b50e8fbe7d7fe76103e09a70b143d9316d/aws-ts-ec2-provisioners/provisioner.ts 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?
m

millions-soccer-19656

04/17/2019, 3:38 PM
@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.
f

fierce-carpet-95079

04/17/2019, 4:08 PM
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.
3 Views