Skip to content

Commit ad5a3fd

Browse files
Paginate ListHostedZones when listing hosted zones
listHostedZones called ListHostedZones once with no pagination. The AWS API returns at most 100 zones per page, so accounts with more than 100 hosted zones silently dropped zones beyond the first page. GetHostedZoneID then reported "no hosted zone found" for valid domains whose parent zone landed on a later page. Loop over pages using IsTruncated/NextMarker until all zones are listed. Fixes #4832 Signed-off-by: Shashank Varma <324153016+shashankvarma499@users.noreply.github.com>
1 parent ff98381 commit ad5a3fd

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

pkg/aws/services/route53.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,23 @@ func (c *route53Client) listHostedZones(ctx context.Context) ([]types.HostedZone
8989
return nil, err
9090
}
9191

92-
reqList := &route53.ListHostedZonesInput{}
93-
respList, err := client.ListHostedZones(ctx, reqList)
94-
if err != nil {
95-
return nil, err
92+
// ListHostedZones returns at most 100 zones per page. Paginate so zones
93+
// beyond the first page are not silently dropped.
94+
var zones []types.HostedZone
95+
var marker *string
96+
for {
97+
reqList := &route53.ListHostedZonesInput{Marker: marker}
98+
respList, err := client.ListHostedZones(ctx, reqList)
99+
if err != nil {
100+
return nil, err
101+
}
102+
zones = append(zones, respList.HostedZones...)
103+
if !respList.IsTruncated {
104+
break
105+
}
106+
marker = respList.NextMarker
96107
}
97108

98-
c.hostedZonesCache.Set(hostedZonesCacheKey, respList.HostedZones, c.hostedZonesCacheTTL)
99-
return respList.HostedZones, nil
109+
c.hostedZonesCache.Set(hostedZonesCacheKey, zones, c.hostedZonesCacheTTL)
110+
return zones, nil
100111
}

0 commit comments

Comments
 (0)