-
Notifications
You must be signed in to change notification settings - Fork 397
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
route53 - Refactor to use boto3 #405
Conversation
16ac56c
to
0442fed
Compare
17df4a1
to
94705bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to migrate this module to boto3. That the integration tests pass is certainly a good start.
I've not had chance to run through most of the code, but there are a number of helpers which should make things easier for you.
See also: https://docs.ansible.com/ansible/devel/dev_guide/platforms/aws_guidelines.html
In general:
- use
module.fail_json_aws(e, msg="Some message")
rather thanmodule.fail_json(msg=e)
- use
is_boto3_error_message
/is_boto3_error_code
rather than trying to catch the API specific exceptions - we also have a 'retry' decorator which is helpful on busy accounts as it will automatically retry on things like API ratelimiting exceptions https://docs.ansible.com/ansible/devel/dev_guide/platforms/aws_guidelines.html#api-throttling-rate-limiting-and-pagination (Looks like I need to check for a couple of old examples that still try to use
e.response['Error']
)
94705bd
to
beb94da
Compare
Hi @tremble, Thank you very much for the help and quick reply. I have performed the changes based on the guide and your suggestions. |
beb94da
to
e6fc908
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see the paginated queries split into their own small functions, just doing the pagination, and we can use scrub_non_params rather than our own function. But other than that I think this PR is ready to roll. Thanks for working on this.
resource_record_set['ResourceRecords'] = sorted(resource_record_set['ResourceRecords'], key=itemgetter('Value')) | ||
|
||
if command_in == 'create' and aws_record == resource_record_set: | ||
module.exit_json(changed=False) | ||
|
||
if command_in == 'get': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mentioned being interested in helping with community.aws in general. Not as part of this PR, but a separate PR we should probably deprecate the 'get' command here.
You'll notice that in tests/sanity/ignore-2.11.txt there's an entry
plugins/modules/route53.py validate-modules:parameter-state-invalid-choice
Do not add get, list or info state options to an existing module - create a new _info or _facts module
'get' commands are generally better handled by a dedicated _info module. I believe route53_info can be used to do this so if you're willing to raise a follow up PR it would be appreciated
* Refactor route53 module to use boto3 instead of boto
e6fc908
to
4d069a5
Compare
Thanks for you work on this. Should be available in community.aws:1.4.0 |
* route53 - Refactor to use boto3 * Changelog Co-authored-by: Mark Chappell <[email protected]>
Just re-downloaded community.aws:1.4.0 and it complains that
While the following is ok:
|
@tremble is there anyway I can help you to debug this? [Having route53 work with profiles will be a huge plus as I'll delete a huge chunk of ansible code that does sts_assume_role saves the result in a variable... etc... ] |
@eRadical, WFM...
One key piece is that "profile" is passed directly to the boto3 library, if you don't use "local", then you'll need to make sure that the profile is available wherever the module is actually being executed (note: this will be the Ansible target not the controller.) |
* route53 - Refactor to use boto3 * Changelog Co-authored-by: Mark Chappell <[email protected]>
* route53 - Refactor to use boto3 * Changelog Co-authored-by: Mark Chappell <[email protected]>
* route53 - Refactor to use boto3 * Changelog Co-authored-by: Mark Chappell <[email protected]>
…e-collections#405) Remove "missing credentials" tests from ec2_group/ec2_vpc_net SUMMARY AWS Client creation is now done inside a helper module which is more thoroughly tested. Remove the extra tests from ec2_vpc_net and ec2_group. They bring no significant value but do bump up the login failure count, which can result in the IPs getting temporarily black-listed ISSUE TYPE Feature Pull Request COMPONENT NAME ec2_group ec2_vpc_net ADDITIONAL INFORMATION For more thorough tests look at the module_utils_core tests Reviewed-by: Jill R <None> Reviewed-by: None <None>
* route53 - Refactor to use boto3 * Changelog Co-authored-by: Mark Chappell <[email protected]> This commit was initially merged in https://github.com/ansible-collections/community.aws See: ansible-collections@08d0b9c
SUMMARY
ISSUE TYPE
COMPONENT NAME
route53 - Refactor to use boto3