From 540e1bbd69f026887044a8db4b796e1cebe1a3e3 Mon Sep 17 00:00:00 2001 From: Robin Miller Date: Thu, 15 Jun 2017 14:06:16 -0500 Subject: [PATCH] [cloud] Route53 Avoid throttling errors and unnecessary processing when checking rrsets. (#22104) The boto Route53 get_all_rrsets method will return the record set matching the name, type, and identifier specified, followed by ALL subsequent sets in alphabetical order based on name. If the specified set does not exist, the method will still return all the sets that _would_ have come after it. Searching through sets we know will not match is not just a waste of resources but, more importantly, often triggers AWS API throttling when used on zones with large numbers of records. --- lib/ansible/modules/cloud/amazon/route53.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/amazon/route53.py b/lib/ansible/modules/cloud/amazon/route53.py index 2e5e468316a..12f096edb14 100644 --- a/lib/ansible/modules/cloud/amazon/route53.py +++ b/lib/ansible/modules/cloud/amazon/route53.py @@ -561,7 +561,14 @@ def main(): record['values'] = sorted(rset.resource_records) if command_in == 'create' and rset.to_xml() == wanted_rset.to_xml(): module.exit_json(changed=False) - break + + # We need to look only at the first rrset returned by the above call, + # so break here. The returned elements begin with the one matching our + # requested name, type, and identifier, if such an element exists, + # followed by all others that come after it in alphabetical order. + # Therefore, if the first set does not match, no subsequent set will + # match either. + break if command_in == 'get': if type_in == 'NS':