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

Ensure all Route53HostedZones are deleted by adding pagination support #815

Merged

Conversation

sbocinec
Copy link
Contributor

@sbocinec sbocinec commented Dec 17, 2024

Description

Add pagination support for Route53HostedZones resource to list and delete all existing resources. Currently, the list operation did only a single request so it was only able to delete 100 HostedZones/Records (default max number of the element returned by the ListHostedZone / ListResourceRecordSets API calls.

Ref: https://github.com/aws/aws-sdk-go-v2/blob/service/route53/v1.46.3/service/route53/api_op_ListHostedZones.go#L38-L63

Fixes #817.

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.
  • Attention Grunts - if this PR adds support for a new resource, ensure the nuke_sandbox and nuke_phxdevops jobs in .circleci/config.yml have been updated with appropriate exclusions (either directly in the job or via the .circleci/nuke_config.yml file) to prevent nuking IAM roles, groups, resources, etc that are important for the test accounts.

Release Notes (draft)

Add Route53HostedZones pagination support to list & delete all hosted zones [X].

Migration Guide

@sbocinec sbocinec changed the title [WIP] Route53 hosted zone pagination [WIP] Fix Route53HostedZone pagination Dec 17, 2024
@sbocinec sbocinec changed the title [WIP] Fix Route53HostedZone pagination Ensure all Route53HostedZones are deleted by adding pagination support Dec 17, 2024
logging.Errorf("[Failed] unable to list resource record set: %s", err)
return err
}
for {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn’t using NewListResourceRecordSetsPaginator be easier? You could then use HasMorePages() as an iterator for the loop, e.q. example from docs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! I have updated the PR

@sbocinec sbocinec force-pushed the route53-hosted-zone-pagination branch from 4562e37 to 3a987d4 Compare December 18, 2024 16:20
marker *string
)

for {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one could also use a paginator NewListHostedZonesPaginator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have already updated the PR.

Add pagination support to list/nuke all hosted zones as the list
response is truncated when there many hosted zones exist.
@sbocinec sbocinec force-pushed the route53-hosted-zone-pagination branch from 3a987d4 to 5e875b9 Compare December 19, 2024 08:40
Copy link
Contributor

@james03160927 james03160927 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Will trigger tests for this.

@james03160927
Copy link
Contributor

Passed all the tests. Good to merge the change now. Thanks for the contribution!

@james03160927 james03160927 merged commit 0f0e069 into gruntwork-io:master Dec 21, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

Route53HostedZones deletes max 100 hosted zones
3 participants