Skip to content

Commit

Permalink
Change Route53 resources to global resource (gruntwork-io#715)
Browse files Browse the repository at this point in the history
  • Loading branch information
james03160927 authored May 30, 2024
1 parent c544827 commit b305bd4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions aws/resource_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func getRegisteredGlobalResources() []AwsResource {
&resources.IAMRoles{},
&resources.IAMServiceLinkedRoles{},
&resources.OIDCProviders{},
&resources.Route53HostedZone{},
&resources.Route53CidrCollection{},
&resources.Route53TrafficPolicy{},
}
}

Expand Down Expand Up @@ -129,9 +132,6 @@ func getRegisteredRegionalResources() []AwsResource {
&resources.EC2IPAMByoasn{},
&resources.EC2IPAMCustomAllocation{},
&resources.EC2Subnet{},
&resources.Route53HostedZone{},
&resources.Route53CidrCollection{},
&resources.Route53TrafficPolicy{},
&resources.InternetGateway{},
&resources.NetworkInterface{},
&resources.SecurityGroup{},
Expand Down
22 changes: 12 additions & 10 deletions aws/resources/route53_cidr_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ func (r *Route53CidrCollection) nukeCidrLocations(id *string) (err error) {
})
}

_, err = r.Client.ChangeCidrCollectionWithContext(r.Context, &route53.ChangeCidrCollectionInput{
Id: id,
Changes: changes,
})
if err != nil {
logging.Errorf("[Failed] unable to list cidr collections: %v", err)
return err
if len(changes) > 0 {
_, err = r.Client.ChangeCidrCollectionWithContext(r.Context, &route53.ChangeCidrCollectionInput{
Id: id,
Changes: changes,
})
if err != nil {
logging.Errorf("[Failed] unable to list cidr collections: %v", err)
return err
}
}

logging.Debugf("[Route53 CIDR location] Successfully nuked cidr location(s)")
Expand All @@ -63,10 +65,10 @@ func (r *Route53CidrCollection) nukeCidrLocations(id *string) (err error) {

func (r *Route53CidrCollection) nukeAll(identifiers []*string) (err error) {
if len(identifiers) == 0 {
logging.Debugf("No Route53 Cidr collection to nuke in region %s", r.Region)
logging.Debugf("No Route53 Cidr collection to nuke")
return nil
}
logging.Debugf("Deleting all Route53 Cidr collection in region %s", r.Region)
logging.Debugf("Deleting all Route53 Cidr collection")

var deletedIds []*string
for _, id := range identifiers {
Expand Down Expand Up @@ -105,7 +107,7 @@ func (r *Route53CidrCollection) nukeAll(identifiers []*string) (err error) {
}
}

logging.Debugf("[OK] %d Route53 cidr collection(s) deleted in %s", len(deletedIds), r.Region)
logging.Debugf("[OK] %d Route53 cidr collection(s) deleted", len(deletedIds))

return nil
}
2 changes: 1 addition & 1 deletion aws/resources/route53_hostedzone.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/gruntwork-io/cloud-nuke/report"
)

func (r *Route53HostedZone) getAll(c context.Context, configObj config.Config) ([]*string, error) {
func (r *Route53HostedZone) getAll(_ context.Context, configObj config.Config) ([]*string, error) {
var ids []*string

result, err := r.Client.ListHostedZonesWithContext(r.Context, &route53.ListHostedZonesInput{})
Expand Down

0 comments on commit b305bd4

Please sign in to comment.