skip to Main Content

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.

2

Answers


  1. 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.

    Login or Signup to reply.
  2. Custom resource sounds fine, feels like engineering without the over 😁

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search