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

aws: add pagination support to the findRecord func for route53 #3900

Merged
merged 3 commits into from
Apr 2, 2018
Merged

aws: add pagination support to the findRecord func for route53 #3900

merged 3 commits into from
Apr 2, 2018

Conversation

benburkert
Copy link
Contributor

@benburkert benburkert commented Mar 23, 2018

The ListResourceRecordSets API call may return ALIAS records that point to the record specified by the "name" parameter. These records may appear first because the results are lexicographically ordered. When there are more than 100 of these records they can cause the target record to be part of the truncated set.

Check for a truncated indicator in the ListResourceRecordSetsOutput. If the response is truncated, repeat the API call with an updated starting name, type, and identifier. If the response is not truncated, return an r53NoRecordsFound.

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 23, 2018
@bflad bflad added service/route53 Issues and PRs that pertain to the route53 service. bug Addresses a defect in current functionality. labels Mar 23, 2018
@bflad
Copy link
Contributor

bflad commented Mar 27, 2018

Hi @benburkert 👋 Is there any reason to not implement the AWS SDK paginator? https://docs.aws.amazon.com/sdk-for-go/api/service/route53/#Route53.ListResourceRecordSetsPages

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 28, 2018
The ListResourceRecordSets API call may return ALIAS records that point
to the record specified by the "name" parameter. These records may
appear first because the results are lexicographically ordered. When
there are more than 100 of these records they can cause the target
record to be part of the truncated set.

Check for a truncated indicator in the ListResourceRecordSetsOutput. If
the response is truncated, repeat the API call with an updated starting
name, type, and identifier. If the response is not truncated, return an
r53NoRecordsFound.
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 28, 2018
@benburkert
Copy link
Contributor Author

hi @bflad, I was unaware of the ListResourceRecordSetsPages method, so I've updated the PR to use that method for paginating the record sets.

@bflad bflad removed the waiting-response Maintainers are waiting on response from community or contributor. label Mar 29, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Thanks for switching this! Much easier to understand. Can you see my two comments below?

}
var record *route53.ResourceRecordSet
err = conn.ListResourceRecordSetsPages(lopts, func(resp *route53.ListResourceRecordSetsOutput, lastPage bool) bool {
for _, record = range resp.ResourceRecordSets {
Copy link
Contributor

Choose a reason for hiding this comment

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

For clarity, we should utilize a separate variable here instead of the record we want to return, e.g.

for _, recordSet := range respResourceRecordSets {

Then we can set record to the correct value when its correctly found and not introduce the awkward record = nil each loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. 👍

return record, nil

record = nil
return true
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be return !lastPage so we keep looping until the last page?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't seem to make a difference, but I've gone ahead and changed it. 👍

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 29, 2018
@bflad bflad added this to the v1.14.0 milestone Apr 2, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! 🚀

24 tests passed (all tests)
=== RUN   TestAccAWSRoute53Record_weighted_basic
--- PASS: TestAccAWSRoute53Record_weighted_basic (163.11s)
=== RUN   TestAccAWSRoute53Record_basic
--- PASS: TestAccAWSRoute53Record_basic (182.25s)
=== RUN   TestAccAWSRoute53Record_spfSupport
--- PASS: TestAccAWSRoute53Record_spfSupport (186.18s)
=== RUN   TestAccAWSRoute53Record_s3_alias
--- PASS: TestAccAWSRoute53Record_s3_alias (190.88s)
=== RUN   TestAccAWSRoute53Record_generatesSuffix
--- PASS: TestAccAWSRoute53Record_generatesSuffix (191.76s)
=== RUN   TestAccAWSRoute53Record_caaSupport
--- PASS: TestAccAWSRoute53Record_caaSupport (193.40s)
=== RUN   TestAccAWSRoute53Record_importUnderscored
--- PASS: TestAccAWSRoute53Record_importUnderscored (193.48s)
=== RUN   TestAccAWSRoute53Record_aliasUppercase
--- PASS: TestAccAWSRoute53Record_aliasUppercase (195.51s)
=== RUN   TestAccAWSRoute53Record_geolocation_basic
--- PASS: TestAccAWSRoute53Record_geolocation_basic (218.63s)
=== RUN   TestAccAWSRoute53Record_latency_basic
--- PASS: TestAccAWSRoute53Record_latency_basic (222.98s)
=== RUN   TestAccAWSRoute53Record_failover
--- PASS: TestAccAWSRoute53Record_failover (227.96s)
=== RUN   TestAccAWSRoute53Record_txtSupport
--- PASS: TestAccAWSRoute53Record_txtSupport (229.74s)
=== RUN   TestAccAWSRoute53Record_alias
--- PASS: TestAccAWSRoute53Record_alias (230.42s)
=== RUN   TestAccAWSRoute53Record_TypeChange
--- PASS: TestAccAWSRoute53Record_TypeChange (242.84s)
=== RUN   TestAccAWSRoute53Record_basic_fqdn
--- PASS: TestAccAWSRoute53Record_basic_fqdn (244.98s)
=== RUN   TestAccAWSRoute53Record_SetIdentiferChange
--- PASS: TestAccAWSRoute53Record_SetIdentiferChange (247.43s)
=== RUN   TestAccAWSRoute53Record_importBasic
--- PASS: TestAccAWSRoute53Record_importBasic (250.40s)
=== RUN   TestAccAWSRoute53Record_AliasChange
--- PASS: TestAccAWSRoute53Record_AliasChange (280.04s)
=== RUN   TestAccAWSRoute53Record_wildcard
--- PASS: TestAccAWSRoute53Record_wildcard (287.57s)
=== RUN   TestAccAWSRoute53Record_empty
--- PASS: TestAccAWSRoute53Record_empty (153.92s)
=== RUN   TestAccAWSRoute53Record_longTXTrecord
--- PASS: TestAccAWSRoute53Record_longTXTrecord (151.72s)
=== RUN   TestAccAWSRoute53Record_multivalue_answer_basic
--- PASS: TestAccAWSRoute53Record_multivalue_answer_basic (172.75s)
=== RUN   TestAccAWSRoute53Record_weighted_alias
--- PASS: TestAccAWSRoute53Record_weighted_alias (387.20s)
=== RUN   TestAccAWSRoute53Record_allowOverwrite
--- PASS: TestAccAWSRoute53Record_allowOverwrite (224.86s)

@bflad bflad merged commit 77aaef0 into hashicorp:master Apr 2, 2018
bflad added a commit that referenced this pull request Apr 2, 2018
@bflad
Copy link
Contributor

bflad commented Apr 6, 2018

This has been released in version 1.14.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 6, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/route53 Issues and PRs that pertain to the route53 service. size/M Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants