0

I have a CDK project which creates certain AWS resources including VPC Endpoints. The side-effect is that the corresponding Route53 hosted zone/records will be created by some other services for each VPC Endpoints, the problem is that the hosted zone/records won't get deleted when un-deploying the stack since they are not created explicitly by the stack.

Is there a way to delete those hosted zone/records when un-deploying the stack? Note that the hosted zone ID is hard-coded by Allegiance so it is easy to locate the hosted zones.

My idea is to implement a Custom resource to manipulate a script, when create/update the custom resource it does nothing, but when deleting the custom resource it will trigger a script/lambda function which will find the hosted zone by ID and delete it, is this something sounding possible? This approach sounds over-engineering though.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Yamazaki
  • 3
  • 2

2 Answers2

0

You could write a small script with the SDK to delete the hosted zones and records. Then create a command to execute cdk destroy and run the script.

But if you would implicitly create the hosted zones and records in your stack, it should get deleted when destroying your stack.

Faruk Ada
  • 79
  • 3
0

Custom resource sounds fine, feels like engineering without the over

Neil P
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 15 '22 at 20:16