From 520aa227aa2cd5b69092c98c0cd2ed2d413a86af Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Wed, 27 Jan 2021 09:17:44 +0100 Subject: [PATCH] Bulk migration to fail_json_aws (#361) * 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: https://github.com/ansible-collections/community.aws/commit/6c883156d250d3ed926a21dbd619b2b138246c5d --- plugins/modules/rds_instance.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/modules/rds_instance.py b/plugins/modules/rds_instance.py index 3aa9c7f67dc..169ace0e2fa 100644 --- a/plugins/modules/rds_instance.py +++ b/plugins/modules/rds_instance.py @@ -755,7 +755,6 @@ 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 @@ -763,7 +762,7 @@ from time import sleep try: - from botocore.exceptions import ClientError, BotoCoreError, WaiterError + import botocore except ImportError: pass # caught by AnsibleAWSModule @@ -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 @@ -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')