From b5585a216e4cbb0b7bb9cce4860bf65c9ac524bb Mon Sep 17 00:00:00 2001 From: Preston Norvell Date: Thu, 27 Aug 2020 18:09:47 -0700 Subject: [PATCH] Paginate aws_reoute53_route_association --- aws/resource_aws_route53_zone_association.go | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/aws/resource_aws_route53_zone_association.go b/aws/resource_aws_route53_zone_association.go index 6d018711666..4e88e0c1ccb 100644 --- a/aws/resource_aws_route53_zone_association.go +++ b/aws/resource_aws_route53_zone_association.go @@ -214,19 +214,25 @@ func route53GetZoneAssociation(conn *route53.Route53, zoneID, vpcID, vpcRegion s VPCRegion: aws.String(vpcRegion), } - output, err := conn.ListHostedZonesByVPC(input) + for { + output, err := conn.ListHostedZonesByVPC(input) - if err != nil { - return nil, err - } + if err != nil { + return nil, err + } - var associatedHostedZoneSummary *route53.HostedZoneSummary - for _, hostedZoneSummary := range output.HostedZoneSummaries { - if zoneID == aws.StringValue(hostedZoneSummary.HostedZoneId) { - associatedHostedZoneSummary = hostedZoneSummary + var associatedHostedZoneSummary *route53.HostedZoneSummary + for _, hostedZoneSummary := range output.HostedZoneSummaries { + if zoneID == aws.StringValue(hostedZoneSummary.HostedZoneId) { + associatedHostedZoneSummary = hostedZoneSummary + return associatedHostedZoneSummary, nil + } + } + if output.NextToken == nil { break } + input.NextToken = output.NextToken } - return associatedHostedZoneSummary, nil + return nil, nil }