Skip to content

Commit

Permalink
Bulk migration to fail_json_aws (ansible-collections#361)
Browse files Browse the repository at this point in the history
* Split imports and sort
* Move camel_dict_to_snake_dict imports to ansible.module_utils.common.dict_transformations
* Cleanup unused imports
* Bulk migration to fail_json_aws
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6c88315
  • Loading branch information
tremble authored and alinabuzachis committed Sep 9, 2022
1 parent f67260f commit 8b90d98
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions plugins/modules/rds_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,15 +755,14 @@
get_rds_method_attribute,
get_tags,
)
from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter
from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ansible_dict_to_boto3_tag_list, AWSRetry
from ansible.module_utils.six import string_types

from time import sleep

try:
from botocore.exceptions import ClientError, BotoCoreError, WaiterError
import botocore
except ImportError:
pass # caught by AnsibleAWSModule

Expand Down Expand Up @@ -807,7 +806,7 @@ def get_instance(client, module, db_instance_id):
sleep(3)
else:
instance = {}
except (BotoCoreError, ClientError) as e: # pylint: disable=duplicate-except
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except
module.fail_json_aws(e, msg='Failed to describe DB instances')
return instance

Expand All @@ -820,7 +819,7 @@ def get_final_snapshot(client, module, snapshot_identifier):
return {}
except is_boto3_error_code('DBSnapshotNotFound') as e: # May not be using wait: True
return {}
except (BotoCoreError, ClientError) as e: # pylint: disable=duplicate-except
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except
module.fail_json_aws(e, msg='Failed to retrieve information about the final snapshot')


Expand Down

0 comments on commit 8b90d98

Please sign in to comment.