From 146fe7b76e6fa98506040bd822de4f9abffe4102 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Thu, 28 Sep 2023 09:35:21 +0200 Subject: [PATCH] Apply isort formatting --- plugins/action/s3_object.py | 5 +++- plugins/callback/aws_resource_actions.py | 2 +- plugins/inventory/aws_ec2.py | 4 +--- plugins/inventory/aws_rds.py | 3 +-- plugins/lookup/aws_service_ip_ranges.py | 4 ++-- plugins/lookup/secretsmanager_secret.py | 3 +-- plugins/lookup/ssm_parameter.py | 5 ++-- plugins/module_utils/acm.py | 3 ++- plugins/module_utils/backup.py | 1 + plugins/module_utils/botocore.py | 3 ++- plugins/module_utils/cloud.py | 2 +- plugins/module_utils/cloudfront_facts.py | 3 ++- plugins/module_utils/core.py | 2 +- plugins/module_utils/ec2.py | 23 +++++++++---------- plugins/module_utils/elb_utils.py | 3 ++- plugins/module_utils/elbv2.py | 9 ++++---- plugins/module_utils/modules.py | 6 ++--- plugins/module_utils/policy.py | 3 +-- plugins/module_utils/rds.py | 4 +++- plugins/module_utils/transformation.py | 2 +- plugins/module_utils/waf.py | 1 - plugins/module_utils/waiters.py | 1 - plugins/modules/autoscaling_group.py | 8 +++---- plugins/modules/autoscaling_group_info.py | 2 +- plugins/modules/aws_az_info.py | 3 ++- plugins/modules/aws_caller_info.py | 3 ++- plugins/modules/backup_plan.py | 4 +++- plugins/modules/backup_plan_info.py | 2 +- plugins/modules/backup_selection.py | 11 +++++---- plugins/modules/backup_selection_info.py | 5 ++-- plugins/modules/backup_tag.py | 5 ++-- plugins/modules/backup_tag_info.py | 2 +- plugins/modules/backup_vault.py | 10 ++++---- plugins/modules/backup_vault_info.py | 2 +- plugins/modules/cloudformation.py | 4 ++-- plugins/modules/cloudformation_info.py | 2 +- plugins/modules/cloudtrail.py | 3 ++- plugins/modules/cloudwatch_metric_alarm.py | 3 ++- .../modules/cloudwatch_metric_alarm_info.py | 3 ++- plugins/modules/cloudwatchevent_rule.py | 2 +- plugins/modules/cloudwatchlogs_log_group.py | 2 +- .../modules/cloudwatchlogs_log_group_info.py | 2 +- plugins/modules/ec2_ami.py | 6 ++--- plugins/modules/ec2_ami_info.py | 7 +++--- plugins/modules/ec2_eip.py | 4 ++-- plugins/modules/ec2_eip_info.py | 5 ++-- plugins/modules/ec2_eni.py | 6 ++--- plugins/modules/ec2_eni_info.py | 4 ++-- plugins/modules/ec2_instance.py | 2 +- plugins/modules/ec2_instance_info.py | 2 +- plugins/modules/ec2_key.py | 10 ++++---- plugins/modules/ec2_key_info.py | 4 ++-- plugins/modules/ec2_metadata_facts.py | 4 ++-- plugins/modules/ec2_security_group.py | 12 +++++----- plugins/modules/ec2_security_group_info.py | 5 ++-- plugins/modules/ec2_snapshot.py | 4 ++-- plugins/modules/ec2_snapshot_info.py | 7 +++--- plugins/modules/ec2_spot_instance.py | 7 +++--- plugins/modules/ec2_spot_instance_info.py | 3 ++- plugins/modules/ec2_tag.py | 4 ++-- plugins/modules/ec2_tag_info.py | 2 +- plugins/modules/ec2_vol.py | 12 +++++----- plugins/modules/ec2_vol_info.py | 2 +- plugins/modules/ec2_vpc_dhcp_option.py | 11 +++++---- plugins/modules/ec2_vpc_dhcp_option_info.py | 4 ++-- plugins/modules/ec2_vpc_endpoint.py | 10 ++++---- plugins/modules/ec2_vpc_endpoint_info.py | 2 +- .../modules/ec2_vpc_endpoint_service_info.py | 4 ++-- plugins/modules/ec2_vpc_igw.py | 9 ++++---- plugins/modules/ec2_vpc_igw_info.py | 5 ++-- plugins/modules/ec2_vpc_nat_gateway.py | 9 ++++---- plugins/modules/ec2_vpc_nat_gateway_info.py | 9 ++++---- plugins/modules/ec2_vpc_net.py | 6 ++--- plugins/modules/ec2_vpc_net_info.py | 4 ++-- plugins/modules/ec2_vpc_route_table.py | 8 +++---- plugins/modules/ec2_vpc_route_table_info.py | 4 ++-- plugins/modules/ec2_vpc_subnet.py | 6 ++--- plugins/modules/ec2_vpc_subnet_info.py | 2 +- plugins/modules/elb_application_lb.py | 19 ++++++++------- plugins/modules/elb_application_lb_info.py | 2 +- plugins/modules/elb_classic_lb.py | 14 +++++------ plugins/modules/iam_group.py | 3 +-- plugins/modules/iam_instance_profile.py | 2 +- plugins/modules/iam_managed_policy.py | 3 +-- plugins/modules/iam_policy.py | 8 ++++--- plugins/modules/iam_policy_info.py | 2 +- plugins/modules/iam_role.py | 3 +-- plugins/modules/iam_role_info.py | 3 +-- plugins/modules/iam_user_info.py | 5 ++-- plugins/modules/kms_key.py | 7 +++--- plugins/modules/kms_key_info.py | 2 +- plugins/modules/lambda.py | 10 ++++---- plugins/modules/lambda_event.py | 7 +++--- plugins/modules/lambda_execute.py | 2 +- plugins/modules/lambda_policy.py | 3 ++- plugins/modules/rds_cluster.py | 12 +++++----- plugins/modules/rds_cluster_info.py | 9 ++++---- plugins/modules/rds_cluster_snapshot.py | 17 +++++++------- plugins/modules/rds_instance.py | 11 ++++----- plugins/modules/rds_instance_info.py | 10 ++++---- plugins/modules/rds_instance_snapshot.py | 12 ++++++---- plugins/modules/rds_option_group.py | 13 +++++------ plugins/modules/rds_option_group_info.py | 6 ++--- plugins/modules/rds_param_group.py | 4 ++-- plugins/modules/rds_snapshot_info.py | 5 ++-- plugins/modules/rds_subnet_group.py | 10 ++++---- plugins/modules/route53.py | 4 ++-- plugins/modules/route53_health_check.py | 2 +- plugins/modules/route53_info.py | 3 ++- plugins/modules/route53_zone.py | 6 +++-- plugins/plugin_utils/base.py | 3 +-- plugins/plugin_utils/inventory.py | 2 +- .../library/example_module.py | 3 ++- .../setup_sshkey/files/ec2-fingerprint.py | 1 + .../module_utils/botocore/test_aws_region.py | 5 ++-- .../module_utils/botocore/test_boto3_conn.py | 5 ++-- .../botocore/test_connection_info.py | 5 ++-- .../botocore/test_is_boto3_error_code.py | 2 +- .../botocore/test_is_boto3_error_message.py | 2 +- .../botocore/test_merge_botocore_config.py | 3 ++- .../botocore/test_sdk_versions.py | 11 ++++----- .../module_utils/cloud/test_cloud_retry.py | 1 + .../cloud/test_decorator_generation.py | 5 ++-- .../module_utils/cloud/test_retry_func.py | 3 ++- tests/unit/module_utils/conftest.py | 5 ++-- .../exceptions/test_exceptions.py | 3 ++- .../ansible_aws_module/test_fail_json_aws.py | 3 ++- .../test_minimal_versions.py | 5 ++-- .../ansible_aws_module/test_passthrough.py | 7 +++--- .../test_require_at_least.py | 3 ++- .../module_utils/policy/test_canonicalize.py | 2 +- .../module_utils/retries/test_awsretry.py | 2 +- .../retries/test_retry_wrapper.py | 7 +++--- tests/unit/module_utils/test_acm.py | 9 ++++---- .../module_utils/test_cloudfront_facts.py | 12 +++++----- tests/unit/module_utils/test_iam.py | 3 ++- tests/unit/module_utils/test_rds.py | 3 ++- tests/unit/module_utils/test_s3.py | 7 ++++-- tests/unit/plugin_utils/base/test_plugin.py | 7 +++--- .../botocore/test_boto3_conn_plugin.py | 5 ++-- .../botocore/test_get_aws_region.py | 5 ++-- .../botocore/test_get_connection_info.py | 5 ++-- .../connection/test_connection_base.py | 5 ++-- .../inventory/test_inventory_base.py | 6 +++-- .../inventory/test_inventory_clients.py | 4 ++-- .../plugin_utils/lookup/test_lookup_base.py | 5 ++-- tests/unit/plugins/inventory/test_aws_ec2.py | 18 ++++++++------- tests/unit/plugins/inventory/test_aws_rds.py | 21 ++++++++--------- tests/unit/plugins/modules/conftest.py | 2 +- .../test_build_run_instance_spec.py | 3 ++- .../ec2_instance/test_determine_iam_role.py | 5 ++-- .../ec2_security_group/test_expand_rules.py | 3 ++- .../ec2_security_group/test_formatting.py | 3 ++- .../test_get_target_from_rule.py | 3 ++- .../ec2_security_group/test_validate_ip.py | 5 ++-- .../ec2_security_group/test_validate_rule.py | 2 +- .../modules/test_backup_restore_job_info.py | 4 +++- .../plugins/modules/test_cloudformation.py | 14 +++++------ tests/unit/plugins/modules/test_ec2_ami.py | 2 +- .../unit/plugins/modules/test_ec2_ami_info.py | 9 ++++++-- .../unit/plugins/modules/test_ec2_eni_info.py | 3 ++- tests/unit/plugins/modules/test_ec2_key.py | 8 +++---- .../modules/test_ec2_metadata_facts.py | 3 ++- .../plugins/modules/test_ec2_snapshot_info.py | 7 +++--- .../modules/test_ec2_vpc_dhcp_option.py | 6 ++--- tests/unit/plugins/modules/test_kms_key.py | 1 - .../unit/plugins/modules/test_lambda_layer.py | 5 +++- .../plugins/modules/test_lambda_layer_info.py | 6 +++-- .../plugins/modules/test_rds_instance_info.py | 6 ++--- tests/unit/plugins/modules/test_s3_object.py | 2 +- tests/unit/utils/amazon_placebo_fixtures.py | 5 +++- 171 files changed, 494 insertions(+), 410 deletions(-) diff --git a/plugins/action/s3_object.py b/plugins/action/s3_object.py index bc1882680a..f78a42fa39 100644 --- a/plugins/action/s3_object.py +++ b/plugins/action/s3_object.py @@ -6,7 +6,10 @@ import os -from ansible.errors import AnsibleError, AnsibleAction, AnsibleActionFail, AnsibleFileNotFound +from ansible.errors import AnsibleAction +from ansible.errors import AnsibleActionFail +from ansible.errors import AnsibleError +from ansible.errors import AnsibleFileNotFound from ansible.module_utils._text import to_text from ansible.plugins.action import ActionBase from ansible.utils.vars import merge_hash diff --git a/plugins/callback/aws_resource_actions.py b/plugins/callback/aws_resource_actions.py index 7a36bcb364..5ae1777c05 100644 --- a/plugins/callback/aws_resource_actions.py +++ b/plugins/callback/aws_resource_actions.py @@ -33,8 +33,8 @@ # """ -from ansible.plugins.callback import CallbackBase from ansible.module_utils._text import to_native +from ansible.plugins.callback import CallbackBase class CallbackModule(CallbackBase): diff --git a/plugins/inventory/aws_ec2.py b/plugins/inventory/aws_ec2.py index d146aad987..1fd47221d2 100644 --- a/plugins/inventory/aws_ec2.py +++ b/plugins/inventory/aws_ec2.py @@ -275,13 +275,11 @@ from ansible.module_utils._text import to_text from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict - from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.plugin_utils.inventory import AWSInventoryBase - # The mappings give an array of keys to get from the filter name to the value # returned by boto3's EC2 describe_instances method. diff --git a/plugins/inventory/aws_rds.py b/plugins/inventory/aws_rds.py index de146628cf..430329c7e7 100644 --- a/plugins/inventory/aws_rds.py +++ b/plugins/inventory/aws_rds.py @@ -87,9 +87,8 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict - +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.plugin_utils.inventory import AWSInventoryBase diff --git a/plugins/lookup/aws_service_ip_ranges.py b/plugins/lookup/aws_service_ip_ranges.py index 6c32207ea1..fab016c7b2 100644 --- a/plugins/lookup/aws_service_ip_ranges.py +++ b/plugins/lookup/aws_service_ip_ranges.py @@ -46,12 +46,12 @@ import json from ansible.errors import AnsibleLookupError +from ansible.module_utils._text import to_native from ansible.module_utils.six.moves.urllib.error import HTTPError from ansible.module_utils.six.moves.urllib.error import URLError -from ansible.module_utils._text import to_native from ansible.module_utils.urls import ConnectionError -from ansible.module_utils.urls import open_url from ansible.module_utils.urls import SSLValidationError +from ansible.module_utils.urls import open_url from ansible.plugins.lookup import LookupBase diff --git a/plugins/lookup/secretsmanager_secret.py b/plugins/lookup/secretsmanager_secret.py index 5029eadf50..aec0ce1dc9 100644 --- a/plugins/lookup/secretsmanager_secret.py +++ b/plugins/lookup/secretsmanager_secret.py @@ -127,13 +127,12 @@ pass # Handled by AWSLookupBase from ansible.errors import AnsibleLookupError -from ansible.module_utils.six import string_types from ansible.module_utils._text import to_native +from ansible.module_utils.six import string_types from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_message from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry - from ansible_collections.amazon.aws.plugins.plugin_utils.lookup import AWSLookupBase diff --git a/plugins/lookup/ssm_parameter.py b/plugins/lookup/ssm_parameter.py index dad4357a0f..69ef0fb244 100644 --- a/plugins/lookup/ssm_parameter.py +++ b/plugins/lookup/ssm_parameter.py @@ -132,13 +132,12 @@ from ansible.errors import AnsibleLookupError from ansible.module_utils._text import to_native -from ansible.utils.display import Display from ansible.module_utils.six import string_types +from ansible.utils.display import Display from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry - +from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict from ansible_collections.amazon.aws.plugins.plugin_utils.lookup import AWSLookupBase display = Display() diff --git a/plugins/module_utils/acm.py b/plugins/module_utils/acm.py index e7fee816f9..ab3a9f0737 100644 --- a/plugins/module_utils/acm.py +++ b/plugins/module_utils/acm.py @@ -16,7 +16,8 @@ """ try: - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass diff --git a/plugins/module_utils/backup.py b/plugins/module_utils/backup.py index a9e3e6ed01..907879a8ab 100644 --- a/plugins/module_utils/backup.py +++ b/plugins/module_utils/backup.py @@ -10,6 +10,7 @@ pass # Handled by HAS_BOTO3 from typing import Union + from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict diff --git a/plugins/module_utils/botocore.py b/plugins/module_utils/botocore.py index 1c3f2b5dd7..858e4e5939 100644 --- a/plugins/module_utils/botocore.py +++ b/plugins/module_utils/botocore.py @@ -60,9 +60,9 @@ from ansible.module_utils.six import binary_type from ansible.module_utils.six import text_type +from .common import get_collection_info from .exceptions import AnsibleBotocoreError from .retries import AWSRetry -from .common import get_collection_info MINIMUM_BOTOCORE_VERSION = "1.29.0" MINIMUM_BOTO3_VERSION = "1.26.0" @@ -412,6 +412,7 @@ def enable_placebo(session): pill.record() if "_ANSIBLE_PLACEBO_REPLAY" in os.environ: import shutil + import placebo existing_entries = sorted([int(i) for i in os.listdir(os.environ["_ANSIBLE_PLACEBO_REPLAY"])]) diff --git a/plugins/module_utils/cloud.py b/plugins/module_utils/cloud.py index 86bff20d04..4b2775cb30 100644 --- a/plugins/module_utils/cloud.py +++ b/plugins/module_utils/cloud.py @@ -27,9 +27,9 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import time import functools import random +import time class BackoffIterator: diff --git a/plugins/module_utils/cloudfront_facts.py b/plugins/module_utils/cloudfront_facts.py index c749141b9c..342adc82d2 100644 --- a/plugins/module_utils/cloudfront_facts.py +++ b/plugins/module_utils/cloudfront_facts.py @@ -22,9 +22,10 @@ except ImportError: pass +from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict + from .retries import AWSRetry from .tagging import boto3_tag_list_to_ansible_dict -from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict class CloudFrontFactsServiceManagerFailure(Exception): diff --git a/plugins/module_utils/core.py b/plugins/module_utils/core.py index e25b1444b5..44fd1d80be 100644 --- a/plugins/module_utils/core.py +++ b/plugins/module_utils/core.py @@ -42,9 +42,9 @@ # Used to live here, moved into ansible_collections.amazon.aws.plugins.module_utils.botocore from .botocore import HAS_BOTO3 # pylint: disable=unused-import +from .botocore import get_boto3_client_method_parameters # pylint: disable=unused-import from .botocore import is_boto3_error_code # pylint: disable=unused-import from .botocore import is_boto3_error_message # pylint: disable=unused-import -from .botocore import get_boto3_client_method_parameters # pylint: disable=unused-import from .botocore import normalize_boto3_result # pylint: disable=unused-import # Used to live here, moved into ansible_collections.amazon.aws.plugins.module_utils.exceptions diff --git a/plugins/module_utils/ec2.py b/plugins/module_utils/ec2.py index de9d91b56a..b6e5e6f308 100644 --- a/plugins/module_utils/ec2.py +++ b/plugins/module_utils/ec2.py @@ -40,14 +40,14 @@ import re from ansible.module_utils.ansible_release import __version__ -from ansible.module_utils.six import string_types -from ansible.module_utils.six import integer_types # Used to live here, moved into ansible.module_utils.common.dict_transformations from ansible.module_utils.common.dict_transformations import _camel_to_snake # pylint: disable=unused-import from ansible.module_utils.common.dict_transformations import _snake_to_camel # pylint: disable=unused-import from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict # pylint: disable=unused-import from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict # pylint: disable=unused-import +from ansible.module_utils.six import integer_types +from ansible.module_utils.six import string_types # Used to live here, moved into # ansible_collections.amazon.aws.plugins.module_utils.arn from .arn import is_outpost_arn as is_outposts_arn # pylint: disable=unused-import @@ -57,9 +57,8 @@ from .botocore import boto3_conn # pylint: disable=unused-import from .botocore import boto3_inventory_conn # pylint: disable=unused-import from .botocore import boto_exception # pylint: disable=unused-import -from .botocore import get_aws_region # pylint: disable=unused-import from .botocore import get_aws_connection_info # pylint: disable=unused-import - +from .botocore import get_aws_region # pylint: disable=unused-import from .botocore import paginated_query_with_retries # Used to live here, moved into ansible_collections.amazon.aws.plugins.module_utils.exceptions @@ -70,6 +69,14 @@ from .modules import _aws_common_argument_spec as aws_common_argument_spec # pylint: disable=unused-import from .modules import aws_argument_spec as ec2_argument_spec # pylint: disable=unused-import +# Used to live here, moved into # ansible_collections.amazon.aws.plugins.module_utils.policy +from .policy import _py3cmp as py3cmp # pylint: disable=unused-import +from .policy import compare_policies # pylint: disable=unused-import +from .policy import sort_json_policy_dict # pylint: disable=unused-import + +# Used to live here, moved into # ansible_collections.amazon.aws.plugins.module_utils.retries +from .retries import AWSRetry # pylint: disable=unused-import + # Used to live here, moved into ansible_collections.amazon.aws.plugins.module_utils.tagging from .tagging import ansible_dict_to_boto3_tag_list # pylint: disable=unused-import from .tagging import boto3_tag_list_to_ansible_dict # pylint: disable=unused-import @@ -79,14 +86,6 @@ from .transformation import ansible_dict_to_boto3_filter_list # pylint: disable=unused-import from .transformation import map_complex_type # pylint: disable=unused-import -# Used to live here, moved into # ansible_collections.amazon.aws.plugins.module_utils.policy -from .policy import _py3cmp as py3cmp # pylint: disable=unused-import -from .policy import compare_policies # pylint: disable=unused-import -from .policy import sort_json_policy_dict # pylint: disable=unused-import - -# Used to live here, moved into # ansible_collections.amazon.aws.plugins.module_utils.retries -from .retries import AWSRetry # pylint: disable=unused-import - try: import botocore except ImportError: diff --git a/plugins/module_utils/elb_utils.py b/plugins/module_utils/elb_utils.py index b9035c4c28..8dc5eabfe6 100644 --- a/plugins/module_utils/elb_utils.py +++ b/plugins/module_utils/elb_utils.py @@ -4,7 +4,8 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) try: - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass diff --git a/plugins/module_utils/elbv2.py b/plugins/module_utils/elbv2.py index 62fcd5dfd0..429d5f7ceb 100644 --- a/plugins/module_utils/elbv2.py +++ b/plugins/module_utils/elbv2.py @@ -7,17 +7,18 @@ from copy import deepcopy try: - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass -from .retries import AWSRetry -from .tagging import ansible_dict_to_boto3_tag_list -from .tagging import boto3_tag_list_to_ansible_dict from .ec2 import get_ec2_security_group_ids_from_names from .elb_utils import convert_tg_name_to_arn from .elb_utils import get_elb from .elb_utils import get_elb_listener +from .retries import AWSRetry +from .tagging import ansible_dict_to_boto3_tag_list +from .tagging import boto3_tag_list_to_ansible_dict from .waiters import get_waiter diff --git a/plugins/module_utils/modules.py b/plugins/module_utils/modules.py index 0ea953ba8f..28b29c96ec 100644 --- a/plugins/module_utils/modules.py +++ b/plugins/module_utils/modules.py @@ -48,19 +48,19 @@ # Python 3 from io import StringIO +from ansible.module_utils._text import to_native from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import env_fallback from ansible.module_utils.basic import missing_required_lib from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible.module_utils._text import to_native -from .botocore import boto3_conn from .botocore import boto3_at_least +from .botocore import boto3_conn from .botocore import botocore_at_least from .botocore import check_sdk_version_supported +from .botocore import gather_sdk_versions from .botocore import get_aws_connection_info from .botocore import get_aws_region -from .botocore import gather_sdk_versions from .exceptions import AnsibleBotocoreError from .retries import RetryingBotoClientWrapper diff --git a/plugins/module_utils/policy.py b/plugins/module_utils/policy.py index 470bd19bcc..60b096f84f 100644 --- a/plugins/module_utils/policy.py +++ b/plugins/module_utils/policy.py @@ -30,12 +30,11 @@ from functools import cmp_to_key +import ansible.module_utils.common.warnings as ansible_warnings from ansible.module_utils._text import to_text from ansible.module_utils.six import binary_type from ansible.module_utils.six import string_types -import ansible.module_utils.common.warnings as ansible_warnings - def _canonify_root_arn(arn): # There are multiple ways to specifiy delegation of access to an account diff --git a/plugins/module_utils/rds.py b/plugins/module_utils/rds.py index 5141b5ad62..85cde2e4e1 100644 --- a/plugins/module_utils/rds.py +++ b/plugins/module_utils/rds.py @@ -7,7 +7,9 @@ from time import sleep try: - from botocore.exceptions import BotoCoreError, ClientError, WaiterError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError + from botocore.exceptions import WaiterError except ImportError: pass diff --git a/plugins/module_utils/transformation.py b/plugins/module_utils/transformation.py index c31912ba12..708736fc0e 100644 --- a/plugins/module_utils/transformation.py +++ b/plugins/module_utils/transformation.py @@ -28,8 +28,8 @@ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from ansible.module_utils.six import string_types from ansible.module_utils.six import integer_types +from ansible.module_utils.six import string_types def ansible_dict_to_boto3_filter_list(filters_dict): diff --git a/plugins/module_utils/waf.py b/plugins/module_utils/waf.py index 702822b8e6..5e1cf10717 100644 --- a/plugins/module_utils/waf.py +++ b/plugins/module_utils/waf.py @@ -41,7 +41,6 @@ from .retries import AWSRetry from .waiters import get_waiter - MATCH_LOOKUP = { "byte": { "method": "byte_match_set", diff --git a/plugins/module_utils/waiters.py b/plugins/module_utils/waiters.py index 81c9789617..51d6b45687 100644 --- a/plugins/module_utils/waiters.py +++ b/plugins/module_utils/waiters.py @@ -12,7 +12,6 @@ from ansible_collections.amazon.aws.plugins.module_utils.retries import RetryingBotoClientWrapper - ec2_data = { "version": 2, "waiters": { diff --git a/plugins/modules/autoscaling_group.py b/plugins/modules/autoscaling_group.py index 56389400b2..830470f253 100644 --- a/plugins/modules/autoscaling_group.py +++ b/plugins/modules/autoscaling_group.py @@ -660,13 +660,13 @@ pass # Handled by AnsibleAWSModule from ansible.module_utils._text import to_native +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters ASG_ATTRIBUTES = ( "AvailabilityZones", diff --git a/plugins/modules/autoscaling_group_info.py b/plugins/modules/autoscaling_group_info.py index 8ec36f1bc8..8a39e200b3 100644 --- a/plugins/modules/autoscaling_group_info.py +++ b/plugins/modules/autoscaling_group_info.py @@ -247,8 +247,8 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule def match_asg_tags(tags_to_match, asg): diff --git a/plugins/modules/aws_az_info.py b/plugins/modules/aws_az_info.py index 631f39717f..9bbbb9ffd2 100644 --- a/plugins/modules/aws_az_info.py +++ b/plugins/modules/aws_az_info.py @@ -142,7 +142,8 @@ """ try: - from botocore.exceptions import ClientError, BotoCoreError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # Handled by AnsibleAWSModule diff --git a/plugins/modules/aws_caller_info.py b/plugins/modules/aws_caller_info.py index a6ee1f123a..0ed62fa0c1 100644 --- a/plugins/modules/aws_caller_info.py +++ b/plugins/modules/aws_caller_info.py @@ -57,7 +57,8 @@ """ try: - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # Handled by AnsibleAWSModule diff --git a/plugins/modules/backup_plan.py b/plugins/modules/backup_plan.py index 93bb132f2d..c8e7db92f7 100644 --- a/plugins/modules/backup_plan.py +++ b/plugins/modules/backup_plan.py @@ -257,13 +257,15 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict + from ansible_collections.amazon.aws.plugins.module_utils.backup import get_plan_details from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters try: - from botocore.exceptions import ClientError, BotoCoreError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # Handled by AnsibleAWSModule diff --git a/plugins/modules/backup_plan_info.py b/plugins/modules/backup_plan_info.py index 8f0f0f1d72..096857d5b1 100644 --- a/plugins/modules/backup_plan_info.py +++ b/plugins/modules/backup_plan_info.py @@ -105,9 +105,9 @@ pass # Handled by AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.backup import get_plan_details from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.backup import get_plan_details def get_backup_plan_detail(client, module): diff --git a/plugins/modules/backup_selection.py b/plugins/modules/backup_selection.py index 01a2d1c428..c734e2b976 100644 --- a/plugins/modules/backup_selection.py +++ b/plugins/modules/backup_selection.py @@ -223,12 +223,13 @@ except ImportError: pass # Handled by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.backup import get_selection_details -from ansible_collections.amazon.aws.plugins.module_utils.backup import get_plan_details -from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict + +from ansible_collections.amazon.aws.plugins.module_utils.backup import get_plan_details +from ansible_collections.amazon.aws.plugins.module_utils.backup import get_selection_details +from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry def check_for_update(current_selection, backup_selection_data, iam_role_arn): diff --git a/plugins/modules/backup_selection_info.py b/plugins/modules/backup_selection_info.py index e984a8a399..e9362e2ac0 100644 --- a/plugins/modules/backup_selection_info.py +++ b/plugins/modules/backup_selection_info.py @@ -111,10 +111,11 @@ except ImportError: pass # Handled by AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + +from ansible_collections.amazon.aws.plugins.module_utils.backup import get_selection_details from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.backup import get_selection_details -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict def main(): diff --git a/plugins/modules/backup_tag.py b/plugins/modules/backup_tag.py index 2781909738..1a7f0833eb 100644 --- a/plugins/modules/backup_tag.py +++ b/plugins/modules/backup_tag.py @@ -107,13 +107,14 @@ """ try: - from botocore.exceptions import ClientError, BotoCoreError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # caught by AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.backup import get_backup_resource_tags from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags -from ansible_collections.amazon.aws.plugins.module_utils.backup import get_backup_resource_tags def manage_tags(module, backup_client): diff --git a/plugins/modules/backup_tag_info.py b/plugins/modules/backup_tag_info.py index fc581d7e1e..91bd375edb 100644 --- a/plugins/modules/backup_tag_info.py +++ b/plugins/modules/backup_tag_info.py @@ -42,8 +42,8 @@ type: dict """ -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.backup import get_backup_resource_tags +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule def main(): diff --git a/plugins/modules/backup_vault.py b/plugins/modules/backup_vault.py index 5ae309d105..86d3a213b8 100644 --- a/plugins/modules/backup_vault.py +++ b/plugins/modules/backup_vault.py @@ -92,14 +92,16 @@ """ -from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + from ansible_collections.amazon.aws.plugins.module_utils.backup import get_backup_resource_tags +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags try: - from botocore.exceptions import ClientError, BotoCoreError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # Handled by AnsibleAWSModule diff --git a/plugins/modules/backup_vault_info.py b/plugins/modules/backup_vault_info.py index 2428b56ca9..3f186a8830 100644 --- a/plugins/modules/backup_vault_info.py +++ b/plugins/modules/backup_vault_info.py @@ -103,10 +103,10 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible_collections.amazon.aws.plugins.module_utils.backup import get_backup_resource_tags from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible_collections.amazon.aws.plugins.module_utils.backup import get_backup_resource_tags def get_backup_vaults(connection, module): diff --git a/plugins/modules/cloudformation.py b/plugins/modules/cloudformation.py index f242a6cc5c..24f4f01f7a 100644 --- a/plugins/modules/cloudformation.py +++ b/plugins/modules/cloudformation.py @@ -333,11 +333,11 @@ from ansible.module_utils._text import to_bytes from ansible.module_utils._text import to_native -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.botocore import boto_exception from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_message +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list -from ansible_collections.amazon.aws.plugins.module_utils.botocore import boto_exception # Set a default, mostly for our integration tests. This will be overridden in # the main() loop to match the parameters we're passed diff --git a/plugins/modules/cloudformation_info.py b/plugins/modules/cloudformation_info.py index d525a4dd40..697b39f007 100644 --- a/plugins/modules/cloudformation_info.py +++ b/plugins/modules/cloudformation_info.py @@ -296,8 +296,8 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_message +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict diff --git a/plugins/modules/cloudtrail.py b/plugins/modules/cloudtrail.py index 1e49e348c9..597d43f1b0 100644 --- a/plugins/modules/cloudtrail.py +++ b/plugins/modules/cloudtrail.py @@ -244,7 +244,8 @@ """ try: - from botocore.exceptions import ClientError, BotoCoreError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # Handled by AnsibleAWSModule diff --git a/plugins/modules/cloudwatch_metric_alarm.py b/plugins/modules/cloudwatch_metric_alarm.py index f248904d64..a1769e8eae 100644 --- a/plugins/modules/cloudwatch_metric_alarm.py +++ b/plugins/modules/cloudwatch_metric_alarm.py @@ -303,10 +303,11 @@ from botocore.exceptions import ClientError except ImportError: pass # protected by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule + def create_metric_alarm(connection, module, params): alarms = connection.describe_alarms(AlarmNames=[params["AlarmName"]]) diff --git a/plugins/modules/cloudwatch_metric_alarm_info.py b/plugins/modules/cloudwatch_metric_alarm_info.py index 454f517926..4f4d14a328 100644 --- a/plugins/modules/cloudwatch_metric_alarm_info.py +++ b/plugins/modules/cloudwatch_metric_alarm_info.py @@ -227,9 +227,10 @@ except ImportError: pass # Handled by AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict @AWSRetry.jittered_backoff(retries=10) diff --git a/plugins/modules/cloudwatchevent_rule.py b/plugins/modules/cloudwatchevent_rule.py index 8f6f1fe573..d39f6264e5 100644 --- a/plugins/modules/cloudwatchevent_rule.py +++ b/plugins/modules/cloudwatchevent_rule.py @@ -190,8 +190,8 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters diff --git a/plugins/modules/cloudwatchlogs_log_group.py b/plugins/modules/cloudwatchlogs_log_group.py index c0a1c6dc1e..e24acfd296 100644 --- a/plugins/modules/cloudwatchlogs_log_group.py +++ b/plugins/modules/cloudwatchlogs_log_group.py @@ -134,8 +134,8 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags diff --git a/plugins/modules/cloudwatchlogs_log_group_info.py b/plugins/modules/cloudwatchlogs_log_group_info.py index 8f313d0e41..0cfe22e22e 100644 --- a/plugins/modules/cloudwatchlogs_log_group_info.py +++ b/plugins/modules/cloudwatchlogs_log_group_info.py @@ -80,8 +80,8 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule def describe_log_group(client, log_group_name, module): diff --git a/plugins/modules/ec2_ami.py b/plugins/modules/ec2_ami.py index 000469ee6a..81bcae9143 100644 --- a/plugins/modules/ec2_ami.py +++ b/plugins/modules/ec2_ami.py @@ -427,11 +427,11 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags from ansible_collections.amazon.aws.plugins.module_utils.ec2 import add_ec2_tags +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter diff --git a/plugins/modules/ec2_ami_info.py b/plugins/modules/ec2_ami_info.py index 29610233bc..2c60f59099 100644 --- a/plugins/modules/ec2_ami_info.py +++ b/plugins/modules/ec2_ami_info.py @@ -200,17 +200,18 @@ """ try: - from botocore.exceptions import ClientError, BotoCoreError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # Handled by AnsibleAWSModule from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list class AmiInfoFailure(Exception): diff --git a/plugins/modules/ec2_eip.py b/plugins/modules/ec2_eip.py index 33ec3ebaea..87f67bdd54 100644 --- a/plugins/modules/ec2_eip.py +++ b/plugins/modules/ec2_eip.py @@ -221,11 +221,11 @@ except ImportError: pass # caught by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags class EipError(Exception): diff --git a/plugins/modules/ec2_eip_info.py b/plugins/modules/ec2_eip_info.py index 846ab10669..f9c7858f50 100644 --- a/plugins/modules/ec2_eip_info.py +++ b/plugins/modules/ec2_eip_info.py @@ -95,7 +95,8 @@ """ try: - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # caught by imported AnsibleAWSModule @@ -103,8 +104,8 @@ from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list def get_eips_details(module): diff --git a/plugins/modules/ec2_eni.py b/plugins/modules/ec2_eni.py index 1d7e774fa4..bf8e76a2bc 100644 --- a/plugins/modules/ec2_eni.py +++ b/plugins/modules/ec2_eni.py @@ -282,13 +282,13 @@ except ImportError: pass # Handled by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags from ansible_collections.amazon.aws.plugins.module_utils.ec2 import get_ec2_security_group_ids_from_names +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter diff --git a/plugins/modules/ec2_eni_info.py b/plugins/modules/ec2_eni_info.py index 33799c589f..5ef36b2581 100644 --- a/plugins/modules/ec2_eni_info.py +++ b/plugins/modules/ec2_eni_info.py @@ -196,11 +196,11 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list def build_request_args(eni_id, filters): diff --git a/plugins/modules/ec2_instance.py b/plugins/modules/ec2_instance.py index eb3dbad646..a857ee58c4 100644 --- a/plugins/modules/ec2_instance.py +++ b/plugins/modules/ec2_instance.py @@ -960,9 +960,9 @@ sample: vpc-0011223344 """ -from collections import namedtuple import time import uuid +from collections import namedtuple try: import botocore diff --git a/plugins/modules/ec2_instance_info.py b/plugins/modules/ec2_instance_info.py index 6977edb970..8a9a0b48ec 100644 --- a/plugins/modules/ec2_instance_info.py +++ b/plugins/modules/ec2_instance_info.py @@ -558,8 +558,8 @@ from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list @AWSRetry.jittered_backoff() diff --git a/plugins/modules/ec2_key.py b/plugins/modules/ec2_key.py index 9084e3b6f5..ea4d7f7e4f 100644 --- a/plugins/modules/ec2_key.py +++ b/plugins/modules/ec2_key.py @@ -161,8 +161,8 @@ version_added: 3.1.0 """ -import uuid import os +import uuid try: import botocore @@ -171,13 +171,13 @@ from ansible.module_utils._text import to_bytes -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags -from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications +from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters class Ec2KeyFailure(Exception): diff --git a/plugins/modules/ec2_key_info.py b/plugins/modules/ec2_key_info.py index 104ae321b8..f9ca60d6cb 100644 --- a/plugins/modules/ec2_key_info.py +++ b/plugins/modules/ec2_key_info.py @@ -115,11 +115,11 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list def list_ec2_key_pairs(connection, module): diff --git a/plugins/modules/ec2_metadata_facts.py b/plugins/modules/ec2_metadata_facts.py index 9d043bf218..26ecaad0ad 100644 --- a/plugins/modules/ec2_metadata_facts.py +++ b/plugins/modules/ec2_metadata_facts.py @@ -440,10 +440,10 @@ import time import zlib -from ansible.module_utils.basic import AnsibleModule from ansible.module_utils._text import to_text -from ansible.module_utils.urls import fetch_url +from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.six.moves.urllib.parse import quote +from ansible.module_utils.urls import fetch_url socket.setdefaulttimeout(5) diff --git a/plugins/modules/ec2_security_group.py b/plugins/modules/ec2_security_group.py index a5dc7f66ed..07dbfa3052 100644 --- a/plugins/modules/ec2_security_group.py +++ b/plugins/modules/ec2_security_group.py @@ -481,7 +481,8 @@ try: import botocore - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # Handled by AnsibleAWSModule @@ -491,18 +492,17 @@ from ansible.module_utils.common.network import to_subnet from ansible.module_utils.six import string_types -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags +from ansible_collections.amazon.aws.plugins.module_utils.iam import get_aws_account_id +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags -from ansible_collections.amazon.aws.plugins.module_utils.iam import get_aws_account_id +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter - Rule = namedtuple("Rule", ["port_range", "protocol", "target", "target_type", "description"]) TARGET_TYPES_ALL = {"ipv4", "ipv6", "group", "ip_prefix"} SOURCE_TYPES_ALL = {"cidr_ip", "cidr_ipv6", "group_id", "group_name", "ip_prefix"} diff --git a/plugins/modules/ec2_security_group_info.py b/plugins/modules/ec2_security_group_info.py index c56f773440..8b7a04ba14 100644 --- a/plugins/modules/ec2_security_group_info.py +++ b/plugins/modules/ec2_security_group_info.py @@ -248,7 +248,8 @@ """ try: - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # caught by AnsibleAWSModule @@ -256,8 +257,8 @@ from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list def main(): diff --git a/plugins/modules/ec2_snapshot.py b/plugins/modules/ec2_snapshot.py index cae97201d4..520fd80ac3 100644 --- a/plugins/modules/ec2_snapshot.py +++ b/plugins/modules/ec2_snapshot.py @@ -211,12 +211,12 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter diff --git a/plugins/modules/ec2_snapshot_info.py b/plugins/modules/ec2_snapshot_info.py index bfa126e0a3..f2db12cbbc 100644 --- a/plugins/modules/ec2_snapshot_info.py +++ b/plugins/modules/ec2_snapshot_info.py @@ -210,17 +210,18 @@ """ try: - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # Handled by AnsibleAWSModule from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list def build_request_args(snapshot_ids, owner_ids, restorable_by_user_ids, filters, max_results, next_token_id): diff --git a/plugins/modules/ec2_spot_instance.py b/plugins/modules/ec2_spot_instance.py index b046f6687c..4f678c626a 100644 --- a/plugins/modules/ec2_spot_instance.py +++ b/plugins/modules/ec2_spot_instance.py @@ -413,13 +413,14 @@ import botocore except ImportError: pass # Handled by AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict + +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code def build_launch_specification(launch_spec): diff --git a/plugins/modules/ec2_spot_instance_info.py b/plugins/modules/ec2_spot_instance_info.py index d530c48fd2..76369b1bf4 100644 --- a/plugins/modules/ec2_spot_instance_info.py +++ b/plugins/modules/ec2_spot_instance_info.py @@ -240,9 +240,10 @@ import botocore except ImportError: pass # Handled by AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list diff --git a/plugins/modules/ec2_tag.py b/plugins/modules/ec2_tag.py index 43197cc2bd..bdfcbccd60 100644 --- a/plugins/modules/ec2_tag.py +++ b/plugins/modules/ec2_tag.py @@ -112,11 +112,11 @@ type: dict """ -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags from ansible_collections.amazon.aws.plugins.module_utils.ec2 import describe_ec2_tags from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags from ansible_collections.amazon.aws.plugins.module_utils.ec2 import remove_ec2_tags +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags def main(): diff --git a/plugins/modules/ec2_tag_info.py b/plugins/modules/ec2_tag_info.py index 8bd826d196..1efcd55822 100644 --- a/plugins/modules/ec2_tag_info.py +++ b/plugins/modules/ec2_tag_info.py @@ -49,8 +49,8 @@ type: dict """ -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.ec2 import describe_ec2_tags +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule def main(): diff --git a/plugins/modules/ec2_vol.py b/plugins/modules/ec2_vol.py index 981510c847..6fa2ca47b1 100644 --- a/plugins/modules/ec2_vol.py +++ b/plugins/modules/ec2_vol.py @@ -248,17 +248,17 @@ import time -from ansible_collections.amazon.aws.plugins.module_utils.arn import is_outpost_arn -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list + +from ansible_collections.amazon.aws.plugins.module_utils.arn import is_outpost_arn +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.ec2 import describe_ec2_tags from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications - +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list try: import botocore diff --git a/plugins/modules/ec2_vol_info.py b/plugins/modules/ec2_vol_info.py index 32ff91968a..c72fb5da25 100644 --- a/plugins/modules/ec2_vol_info.py +++ b/plugins/modules/ec2_vol_info.py @@ -133,8 +133,8 @@ from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list def get_volume_info(volume, region): diff --git a/plugins/modules/ec2_vpc_dhcp_option.py b/plugins/modules/ec2_vpc_dhcp_option.py index 23ac67744b..fc343d5741 100644 --- a/plugins/modules/ec2_vpc_dhcp_option.py +++ b/plugins/modules/ec2_vpc_dhcp_option.py @@ -235,15 +235,16 @@ except ImportError: pass # Handled by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import normalize_ec2_vpc_dhcp_config + +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags -from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import normalize_ec2_vpc_dhcp_config +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications def fetch_dhcp_options_for_vpc(client, module, vpc_id): diff --git a/plugins/modules/ec2_vpc_dhcp_option_info.py b/plugins/modules/ec2_vpc_dhcp_option_info.py index a8c7b1b50d..c97d6a57d1 100644 --- a/plugins/modules/ec2_vpc_dhcp_option_info.py +++ b/plugins/modules/ec2_vpc_dhcp_option_info.py @@ -156,11 +156,11 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import normalize_ec2_vpc_dhcp_config from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import normalize_ec2_vpc_dhcp_config +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list def get_dhcp_options_info(dhcp_option): diff --git a/plugins/modules/ec2_vpc_endpoint.py b/plugins/modules/ec2_vpc_endpoint.py index 02ae8bec9a..c894412eb3 100644 --- a/plugins/modules/ec2_vpc_endpoint.py +++ b/plugins/modules/ec2_vpc_endpoint.py @@ -191,16 +191,16 @@ except ImportError: pass # Handled by AnsibleAWSModule -from ansible.module_utils.six import string_types from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible.module_utils.six import string_types -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.botocore import normalize_boto3_result -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter +from ansible_collections.amazon.aws.plugins.module_utils.botocore import normalize_boto3_result from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications +from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter def get_endpoints(client, module, endpoint_id=None): diff --git a/plugins/modules/ec2_vpc_endpoint_info.py b/plugins/modules/ec2_vpc_endpoint_info.py index e51e44318e..e94cf1a94a 100644 --- a/plugins/modules/ec2_vpc_endpoint_info.py +++ b/plugins/modules/ec2_vpc_endpoint_info.py @@ -179,9 +179,9 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.botocore import normalize_boto3_result +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list diff --git a/plugins/modules/ec2_vpc_endpoint_service_info.py b/plugins/modules/ec2_vpc_endpoint_service_info.py index 050e964a00..e462cfefdb 100644 --- a/plugins/modules/ec2_vpc_endpoint_service_info.py +++ b/plugins/modules/ec2_vpc_endpoint_service_info.py @@ -119,9 +119,9 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list -from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list # We're using a paginator so we can't use the client decorators diff --git a/plugins/modules/ec2_vpc_igw.py b/plugins/modules/ec2_vpc_igw.py index fe5ab51b0b..48db691758 100644 --- a/plugins/modules/ec2_vpc_igw.py +++ b/plugins/modules/ec2_vpc_igw.py @@ -93,13 +93,14 @@ except ImportError: pass # caught by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list +from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter @AWSRetry.jittered_backoff(retries=10, delay=10) diff --git a/plugins/modules/ec2_vpc_igw_info.py b/plugins/modules/ec2_vpc_igw_info.py index 8187a01cc9..66fe76328a 100644 --- a/plugins/modules/ec2_vpc_igw_info.py +++ b/plugins/modules/ec2_vpc_igw_info.py @@ -107,12 +107,13 @@ except ImportError: pass # Handled by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict def get_internet_gateway_info(internet_gateway, convert_tags): diff --git a/plugins/modules/ec2_vpc_nat_gateway.py b/plugins/modules/ec2_vpc_nat_gateway.py index 3586a98806..76f437b9bf 100644 --- a/plugins/modules/ec2_vpc_nat_gateway.py +++ b/plugins/modules/ec2_vpc_nat_gateway.py @@ -250,14 +250,15 @@ except ImportError: pass # Handled by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.ec2 import describe_ec2_tags from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications +from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter @AWSRetry.jittered_backoff(retries=10) diff --git a/plugins/modules/ec2_vpc_nat_gateway_info.py b/plugins/modules/ec2_vpc_nat_gateway_info.py index 96c32c276b..a8c76142a9 100644 --- a/plugins/modules/ec2_vpc_nat_gateway_info.py +++ b/plugins/modules/ec2_vpc_nat_gateway_info.py @@ -149,13 +149,14 @@ except ImportError: pass # Handled by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list -from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict + from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.botocore import normalize_boto3_result +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list @AWSRetry.jittered_backoff(retries=10) diff --git a/plugins/modules/ec2_vpc_net.py b/plugins/modules/ec2_vpc_net.py index afda314ef7..794a49fe91 100644 --- a/plugins/modules/ec2_vpc_net.py +++ b/plugins/modules/ec2_vpc_net.py @@ -207,16 +207,16 @@ except ImportError: pass # Handled by AnsibleAWSModule -from ansible.module_utils.common.network import to_subnet from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible.module_utils.common.network import to_subnet +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_specifications +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter diff --git a/plugins/modules/ec2_vpc_net_info.py b/plugins/modules/ec2_vpc_net_info.py index 1c8a30f84e..93b44fa792 100644 --- a/plugins/modules/ec2_vpc_net_info.py +++ b/plugins/modules/ec2_vpc_net_info.py @@ -152,11 +152,11 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list def describe_vpcs(connection, module): diff --git a/plugins/modules/ec2_vpc_route_table.py b/plugins/modules/ec2_vpc_route_table.py index 45880e6a69..c380c01bf1 100644 --- a/plugins/modules/ec2_vpc_route_table.py +++ b/plugins/modules/ec2_vpc_route_table.py @@ -287,8 +287,8 @@ """ import re -from time import sleep from ipaddress import ip_network +from time import sleep try: import botocore @@ -298,12 +298,12 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.ec2 import describe_ec2_tags from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter diff --git a/plugins/modules/ec2_vpc_route_table_info.py b/plugins/modules/ec2_vpc_route_table_info.py index 21c9fc6674..d330299af3 100644 --- a/plugins/modules/ec2_vpc_route_table_info.py +++ b/plugins/modules/ec2_vpc_route_table_info.py @@ -194,11 +194,11 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list @AWSRetry.jittered_backoff() diff --git a/plugins/modules/ec2_vpc_subnet.py b/plugins/modules/ec2_vpc_subnet.py index c61d9df2bd..e4c420ef4d 100644 --- a/plugins/modules/ec2_vpc_subnet.py +++ b/plugins/modules/ec2_vpc_subnet.py @@ -215,12 +215,12 @@ from ansible.module_utils._text import to_text from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible_collections.amazon.aws.plugins.module_utils.arn import is_outpost_arn +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_tags -from ansible_collections.amazon.aws.plugins.module_utils.arn import is_outpost_arn +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter diff --git a/plugins/modules/ec2_vpc_subnet_info.py b/plugins/modules/ec2_vpc_subnet_info.py index cd83994440..654f5609a3 100644 --- a/plugins/modules/ec2_vpc_subnet_info.py +++ b/plugins/modules/ec2_vpc_subnet_info.py @@ -153,8 +153,8 @@ from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list @AWSRetry.exponential_backoff() diff --git a/plugins/modules/elb_application_lb.py b/plugins/modules/elb_application_lb.py index ec0fec8738..e04ca875d6 100644 --- a/plugins/modules/elb_application_lb.py +++ b/plugins/modules/elb_application_lb.py @@ -526,20 +526,19 @@ except ImportError: pass # caught by AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + +from ansible_collections.amazon.aws.plugins.module_utils.elb_utils import get_elb_listener_rules +from ansible_collections.amazon.aws.plugins.module_utils.elbv2 import ApplicationLoadBalancer +from ansible_collections.amazon.aws.plugins.module_utils.elbv2 import ELBListener +from ansible_collections.amazon.aws.plugins.module_utils.elbv2 import ELBListenerRule +from ansible_collections.amazon.aws.plugins.module_utils.elbv2 import ELBListenerRules +from ansible_collections.amazon.aws.plugins.module_utils.elbv2 import ELBListeners from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags -from ansible_collections.amazon.aws.plugins.module_utils.elbv2 import ( - ApplicationLoadBalancer, - ELBListener, - ELBListenerRule, - ELBListenerRules, - ELBListeners, -) -from ansible_collections.amazon.aws.plugins.module_utils.elb_utils import get_elb_listener_rules +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list @AWSRetry.jittered_backoff() diff --git a/plugins/modules/elb_application_lb_info.py b/plugins/modules/elb_application_lb_info.py index 7964495d66..343f82bc1e 100644 --- a/plugins/modules/elb_application_lb_info.py +++ b/plugins/modules/elb_application_lb_info.py @@ -218,8 +218,8 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict diff --git a/plugins/modules/elb_classic_lb.py b/plugins/modules/elb_classic_lb.py index 5debaf35bb..cbf0b7710b 100644 --- a/plugins/modules/elb_classic_lb.py +++ b/plugins/modules/elb_classic_lb.py @@ -675,18 +675,18 @@ except ImportError: pass # Taken care of by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict + from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import get_ec2_security_group_ids_from_names +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags -from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict - -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import get_ec2_security_group_ids_from_names +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list +from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter diff --git a/plugins/modules/iam_group.py b/plugins/modules/iam_group.py index d9262b424d..d8411191d8 100644 --- a/plugins/modules/iam_group.py +++ b/plugins/modules/iam_group.py @@ -174,9 +174,8 @@ from ansible_collections.amazon.aws.plugins.module_utils.arn import validate_aws_arn from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry - from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry def compare_attached_group_policies(current_attached_policies, new_attached_policies): diff --git a/plugins/modules/iam_instance_profile.py b/plugins/modules/iam_instance_profile.py index b34b6b1305..790fa412d6 100644 --- a/plugins/modules/iam_instance_profile.py +++ b/plugins/modules/iam_instance_profile.py @@ -107,8 +107,8 @@ from copy import deepcopy -from ansible_collections.amazon.aws.plugins.module_utils.iam import add_role_to_iam_instance_profile from ansible_collections.amazon.aws.plugins.module_utils.iam import AnsibleIAMError +from ansible_collections.amazon.aws.plugins.module_utils.iam import add_role_to_iam_instance_profile from ansible_collections.amazon.aws.plugins.module_utils.iam import create_iam_instance_profile from ansible_collections.amazon.aws.plugins.module_utils.iam import delete_iam_instance_profile from ansible_collections.amazon.aws.plugins.module_utils.iam import list_iam_instance_profiles diff --git a/plugins/modules/iam_managed_policy.py b/plugins/modules/iam_managed_policy.py index f1d8e55f9c..2cc7d8da95 100644 --- a/plugins/modules/iam_managed_policy.py +++ b/plugins/modules/iam_managed_policy.py @@ -134,11 +134,10 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule - @AWSRetry.jittered_backoff(retries=5, delay=5, backoff=2.0) def list_policies_with_backoff(): diff --git a/plugins/modules/iam_policy.py b/plugins/modules/iam_policy.py index c2012018c1..1cc9c8cd11 100644 --- a/plugins/modules/iam_policy.py +++ b/plugins/modules/iam_policy.py @@ -102,15 +102,17 @@ import json try: - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass from ansible.module_utils.six import string_types + +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry class PolicyError(Exception): diff --git a/plugins/modules/iam_policy_info.py b/plugins/modules/iam_policy_info.py index 0793b2f895..3e0e4eaaa1 100644 --- a/plugins/modules/iam_policy_info.py +++ b/plugins/modules/iam_policy_info.py @@ -79,8 +79,8 @@ except ImportError: pass -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry diff --git a/plugins/modules/iam_role.py b/plugins/modules/iam_role.py index 404e4aa4e5..f373b2ef63 100644 --- a/plugins/modules/iam_role.py +++ b/plugins/modules/iam_role.py @@ -227,14 +227,13 @@ from ansible_collections.amazon.aws.plugins.module_utils.arn import validate_aws_arn from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule - @AWSRetry.jittered_backoff() def _list_policies(client): diff --git a/plugins/modules/iam_role_info.py b/plugins/modules/iam_role_info.py index b87a281287..b56a35a3e9 100644 --- a/plugins/modules/iam_role_info.py +++ b/plugins/modules/iam_role_info.py @@ -161,11 +161,10 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule - @AWSRetry.jittered_backoff() def list_iam_roles_with_backoff(client, **kwargs): diff --git a/plugins/modules/iam_user_info.py b/plugins/modules/iam_user_info.py index a10c571682..304b449862 100644 --- a/plugins/modules/iam_user_info.py +++ b/plugins/modules/iam_user_info.py @@ -101,14 +101,15 @@ """ try: - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # caught by AnsibleAWSModule from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict diff --git a/plugins/modules/kms_key.py b/plugins/modules/kms_key.py index 9e6bdabfef..82f73b370f 100644 --- a/plugins/modules/kms_key.py +++ b/plugins/modules/kms_key.py @@ -450,14 +450,15 @@ except ImportError: pass # caught by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags -from ansible_collections.amazon.aws.plugins.module_utils.policy import compare_policies @AWSRetry.jittered_backoff(retries=5, delay=5, backoff=2.0) diff --git a/plugins/modules/kms_key_info.py b/plugins/modules/kms_key_info.py index 9733b0d5e1..4ba2499403 100644 --- a/plugins/modules/kms_key_info.py +++ b/plugins/modules/kms_key_info.py @@ -293,8 +293,8 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict diff --git a/plugins/modules/lambda.py b/plugins/modules/lambda.py index 2ef61d6fe8..8b4932a4fb 100644 --- a/plugins/modules/lambda.py +++ b/plugins/modules/lambda.py @@ -389,22 +389,24 @@ import base64 import hashlib -import traceback import re +import traceback from collections import Counter try: - from botocore.exceptions import ClientError, BotoCoreError, WaiterError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError + from botocore.exceptions import WaiterError except ImportError: pass # protected by AnsibleAWSModule from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.iam import get_aws_account_info +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags -from ansible_collections.amazon.aws.plugins.module_utils.iam import get_aws_account_info def get_current_function(connection, function_name, qualifier=None): diff --git a/plugins/modules/lambda_event.py b/plugins/modules/lambda_event.py index 83b0a0737c..0858a54f27 100644 --- a/plugins/modules/lambda_event.py +++ b/plugins/modules/lambda_event.py @@ -138,16 +138,17 @@ import re try: - from botocore.exceptions import ClientError, ParamValidationError, MissingParametersError + from botocore.exceptions import ClientError + from botocore.exceptions import MissingParametersError + from botocore.exceptions import ParamValidationError except ImportError: pass # Handled by AnsibleAWSModule from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import boto3_conn from ansible_collections.amazon.aws.plugins.module_utils.botocore import get_aws_connection_info - +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule # --------------------------------------------------------------------------------------------------- # diff --git a/plugins/modules/lambda_execute.py b/plugins/modules/lambda_execute.py index 10d38d1f59..6b6ff11c53 100644 --- a/plugins/modules/lambda_execute.py +++ b/plugins/modules/lambda_execute.py @@ -139,8 +139,8 @@ except ImportError: pass # Handled by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry diff --git a/plugins/modules/lambda_policy.py b/plugins/modules/lambda_policy.py index b724afa1de..3413d6e79d 100644 --- a/plugins/modules/lambda_policy.py +++ b/plugins/modules/lambda_policy.py @@ -136,8 +136,9 @@ pass # caught by AnsibleAWSModule from ansible.module_utils._text import to_native -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule + from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule def pc(key): diff --git a/plugins/modules/rds_cluster.py b/plugins/modules/rds_cluster.py index b737d98ffe..ca042c67f1 100644 --- a/plugins/modules/rds_cluster.py +++ b/plugins/modules/rds_cluster.py @@ -742,15 +742,15 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list -from ansible_collections.amazon.aws.plugins.module_utils.rds import wait_for_cluster_status +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.rds import arg_spec_to_rds_params -from ansible_collections.amazon.aws.plugins.module_utils.rds import get_tags -from ansible_collections.amazon.aws.plugins.module_utils.rds import ensure_tags from ansible_collections.amazon.aws.plugins.module_utils.rds import call_method +from ansible_collections.amazon.aws.plugins.module_utils.rds import ensure_tags +from ansible_collections.amazon.aws.plugins.module_utils.rds import get_tags +from ansible_collections.amazon.aws.plugins.module_utils.rds import wait_for_cluster_status +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list @AWSRetry.jittered_backoff(retries=10) diff --git a/plugins/modules/rds_cluster_info.py b/plugins/modules/rds_cluster_info.py index 618df5de87..08789af4c6 100644 --- a/plugins/modules/rds_cluster_info.py +++ b/plugins/modules/rds_cluster_info.py @@ -245,12 +245,13 @@ except ImportError: pass # handled by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.rds import get_tags +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list @AWSRetry.jittered_backoff(retries=10) diff --git a/plugins/modules/rds_cluster_snapshot.py b/plugins/modules/rds_cluster_snapshot.py index 134c74af9e..2f0ce49ec6 100644 --- a/plugins/modules/rds_cluster_snapshot.py +++ b/plugins/modules/rds_cluster_snapshot.py @@ -219,17 +219,18 @@ except ImportError: pass # caught by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list -from ansible_collections.amazon.aws.plugins.module_utils.rds import get_tags -from ansible_collections.amazon.aws.plugins.module_utils.rds import ensure_tags -from ansible_collections.amazon.aws.plugins.module_utils.rds import call_method + from ansible_collections.amazon.aws.plugins.module_utils.botocore import get_boto3_client_method_parameters -from ansible_collections.amazon.aws.plugins.module_utils.rds import get_rds_method_attribute +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.rds import arg_spec_to_rds_params +from ansible_collections.amazon.aws.plugins.module_utils.rds import call_method +from ansible_collections.amazon.aws.plugins.module_utils.rds import ensure_tags +from ansible_collections.amazon.aws.plugins.module_utils.rds import get_rds_method_attribute +from ansible_collections.amazon.aws.plugins.module_utils.rds import get_tags +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list def get_snapshot(snapshot_id): diff --git a/plugins/modules/rds_instance.py b/plugins/modules/rds_instance.py index 1436667880..613f5f2d51 100644 --- a/plugins/modules/rds_instance.py +++ b/plugins/modules/rds_instance.py @@ -871,13 +871,10 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible.module_utils.six import string_types -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.botocore import get_boto3_client_method_parameters from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_message -from ansible_collections.amazon.aws.plugins.module_utils.botocore import get_boto3_client_method_parameters -from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.rds import arg_spec_to_rds_params from ansible_collections.amazon.aws.plugins.module_utils.rds import call_method from ansible_collections.amazon.aws.plugins.module_utils.rds import compare_iam_roles @@ -886,7 +883,9 @@ from ansible_collections.amazon.aws.plugins.module_utils.rds import get_rds_method_attribute from ansible_collections.amazon.aws.plugins.module_utils.rds import get_tags from ansible_collections.amazon.aws.plugins.module_utils.rds import update_iam_roles - +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list +from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict valid_engines = [ "aurora", diff --git a/plugins/modules/rds_instance_info.py b/plugins/modules/rds_instance_info.py index afb9ae337d..36c6d1b9c3 100644 --- a/plugins/modules/rds_instance_info.py +++ b/plugins/modules/rds_instance_info.py @@ -351,13 +351,13 @@ sample: sg-abcd1234 """ -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list -from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list try: import botocore diff --git a/plugins/modules/rds_instance_snapshot.py b/plugins/modules/rds_instance_snapshot.py index 8aa5c34fa9..0c67d15836 100644 --- a/plugins/modules/rds_instance_snapshot.py +++ b/plugins/modules/rds_instance_snapshot.py @@ -233,18 +233,20 @@ except ImportError: pass # protected by AnsibleAWSModule -# import module snippets -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + from ansible_collections.amazon.aws.plugins.module_utils.botocore import get_boto3_client_method_parameters from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + +# import module snippets +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.rds import arg_spec_to_rds_params from ansible_collections.amazon.aws.plugins.module_utils.rds import call_method from ansible_collections.amazon.aws.plugins.module_utils.rds import ensure_tags from ansible_collections.amazon.aws.plugins.module_utils.rds import get_rds_method_attribute from ansible_collections.amazon.aws.plugins.module_utils.rds import get_tags +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list def get_snapshot(snapshot_id): diff --git a/plugins/modules/rds_option_group.py b/plugins/modules/rds_option_group.py index f5377bc0ae..c7a9eb64b9 100644 --- a/plugins/modules/rds_option_group.py +++ b/plugins/modules/rds_option_group.py @@ -346,17 +346,16 @@ """ -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags -from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list -from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict - from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible.module_utils.common.dict_transformations import snake_dict_to_camel_dict +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.rds import get_tags +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list +from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags try: import botocore diff --git a/plugins/modules/rds_option_group_info.py b/plugins/modules/rds_option_group_info.py index 290bfad4ef..ef836ce566 100644 --- a/plugins/modules/rds_option_group_info.py +++ b/plugins/modules/rds_option_group_info.py @@ -240,12 +240,12 @@ except ImportError: pass # Handled by AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.rds import get_tags +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry @AWSRetry.jittered_backoff(retries=10) diff --git a/plugins/modules/rds_param_group.py b/plugins/modules/rds_param_group.py index 8211c88c59..abdb57c9b1 100644 --- a/plugins/modules/rds_param_group.py +++ b/plugins/modules/rds_param_group.py @@ -112,12 +112,12 @@ except ImportError: pass # Handled by AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict from ansible.module_utils.parsing.convert_bool import BOOLEANS_TRUE from ansible.module_utils.six import string_types -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict diff --git a/plugins/modules/rds_snapshot_info.py b/plugins/modules/rds_snapshot_info.py index 7fe17e4ee9..9617c5ad8f 100644 --- a/plugins/modules/rds_snapshot_info.py +++ b/plugins/modules/rds_snapshot_info.py @@ -288,11 +288,12 @@ sample: vpc-abcd1234 """ -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict try: import botocore diff --git a/plugins/modules/rds_subnet_group.py b/plugins/modules/rds_subnet_group.py index b43df2c8f0..17fbdb0017 100644 --- a/plugins/modules/rds_subnet_group.py +++ b/plugins/modules/rds_subnet_group.py @@ -178,13 +178,13 @@ """ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule + from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.rds import get_tags +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.rds import ensure_tags - +from ansible_collections.amazon.aws.plugins.module_utils.rds import get_tags +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list try: import botocore diff --git a/plugins/modules/route53.py b/plugins/modules/route53.py index 4abb7b8412..2fb1bce8a2 100644 --- a/plugins/modules/route53.py +++ b/plugins/modules/route53.py @@ -420,10 +420,10 @@ from ansible.module_utils._text import to_native from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_message -from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.transformation import scrub_none_parameters from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter MAX_AWS_RETRIES = 10 # How many retries to perform when an API call is failing diff --git a/plugins/modules/route53_health_check.py b/plugins/modules/route53_health_check.py index b9325cae41..369c7c7740 100644 --- a/plugins/modules/route53_health_check.py +++ b/plugins/modules/route53_health_check.py @@ -300,8 +300,8 @@ from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code +from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.route53 import get_tags from ansible_collections.amazon.aws.plugins.module_utils.route53 import manage_tags diff --git a/plugins/modules/route53_info.py b/plugins/modules/route53_info.py index 769485dda0..909ee0ae37 100644 --- a/plugins/modules/route53_info.py +++ b/plugins/modules/route53_info.py @@ -523,9 +523,10 @@ except ImportError: pass # Handled by AnsibleAWSModule +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict # Split out paginator to allow for the backoff decorator to function diff --git a/plugins/modules/route53_zone.py b/plugins/modules/route53_zone.py index 31c627945f..335c05f167 100644 --- a/plugins/modules/route53_zone.py +++ b/plugins/modules/route53_zone.py @@ -185,13 +185,15 @@ """ import time + from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.route53 import manage_tags from ansible_collections.amazon.aws.plugins.module_utils.route53 import get_tags +from ansible_collections.amazon.aws.plugins.module_utils.route53 import manage_tags try: - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # caught by AnsibleAWSModule diff --git a/plugins/plugin_utils/base.py b/plugins/plugin_utils/base.py index 579f0be5df..3c90662098 100644 --- a/plugins/plugin_utils/base.py +++ b/plugins/plugin_utils/base.py @@ -8,12 +8,11 @@ from ansible.utils.display import Display from ansible_collections.amazon.aws.plugins.module_utils.botocore import check_sdk_version_supported +from ansible_collections.amazon.aws.plugins.module_utils.retries import RetryingBotoClientWrapper from ansible_collections.amazon.aws.plugins.plugin_utils.botocore import boto3_conn from ansible_collections.amazon.aws.plugins.plugin_utils.botocore import get_aws_connection_info from ansible_collections.amazon.aws.plugins.plugin_utils.botocore import get_aws_region -from ansible_collections.amazon.aws.plugins.module_utils.retries import RetryingBotoClientWrapper - display = Display() diff --git a/plugins/plugin_utils/inventory.py b/plugins/plugin_utils/inventory.py index 47eb1887e3..144f77a7a5 100644 --- a/plugins/plugin_utils/inventory.py +++ b/plugins/plugin_utils/inventory.py @@ -14,8 +14,8 @@ from ansible.plugins.inventory import Constructable from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.plugin_utils.botocore import AnsibleBotocoreError from ansible_collections.amazon.aws.plugins.plugin_utils.base import AWSPluginBase +from ansible_collections.amazon.aws.plugins.plugin_utils.botocore import AnsibleBotocoreError def _boto3_session(profile_name=None): diff --git a/tests/integration/targets/module_utils_core/roles/ansibleawsmodule.client/library/example_module.py b/tests/integration/targets/module_utils_core/roles/ansibleawsmodule.client/library/example_module.py index d772a82d6c..e580938e55 100644 --- a/tests/integration/targets/module_utils_core/roles/ansibleawsmodule.client/library/example_module.py +++ b/tests/integration/targets/module_utils_core/roles/ansibleawsmodule.client/library/example_module.py @@ -8,7 +8,8 @@ # of the core behaviour around AWS/Boto3 connection details try: - from botocore.exceptions import BotoCoreError, ClientError + from botocore.exceptions import BotoCoreError + from botocore.exceptions import ClientError except ImportError: pass # Handled by AnsibleAWSModule diff --git a/tests/integration/targets/setup_sshkey/files/ec2-fingerprint.py b/tests/integration/targets/setup_sshkey/files/ec2-fingerprint.py index 827856386d..04d2eb1ea5 100644 --- a/tests/integration/targets/setup_sshkey/files/ec2-fingerprint.py +++ b/tests/integration/targets/setup_sshkey/files/ec2-fingerprint.py @@ -11,6 +11,7 @@ import hashlib import sys + from cryptography.hazmat.primitives import serialization if len(sys.argv) == 0: diff --git a/tests/unit/module_utils/botocore/test_aws_region.py b/tests/unit/module_utils/botocore/test_aws_region.py index a4cab3ccd3..f36967b442 100644 --- a/tests/unit/module_utils/botocore/test_aws_region.py +++ b/tests/unit/module_utils/botocore/test_aws_region.py @@ -3,10 +3,11 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest from unittest.mock import MagicMock -from unittest.mock import sentinel from unittest.mock import call +from unittest.mock import sentinel + +import pytest try: import botocore diff --git a/tests/unit/module_utils/botocore/test_boto3_conn.py b/tests/unit/module_utils/botocore/test_boto3_conn.py index d50cdab83d..d9b19b725f 100644 --- a/tests/unit/module_utils/botocore/test_boto3_conn.py +++ b/tests/unit/module_utils/botocore/test_boto3_conn.py @@ -8,10 +8,11 @@ except ImportError: pass -import pytest from unittest.mock import MagicMock -from unittest.mock import sentinel from unittest.mock import call +from unittest.mock import sentinel + +import pytest import ansible_collections.amazon.aws.plugins.module_utils.botocore as utils_botocore diff --git a/tests/unit/module_utils/botocore/test_connection_info.py b/tests/unit/module_utils/botocore/test_connection_info.py index 7ec4ed2cc3..5cdf45f901 100644 --- a/tests/unit/module_utils/botocore/test_connection_info.py +++ b/tests/unit/module_utils/botocore/test_connection_info.py @@ -4,10 +4,11 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from copy import deepcopy -import pytest from unittest.mock import MagicMock -from unittest.mock import sentinel from unittest.mock import call +from unittest.mock import sentinel + +import pytest try: import botocore diff --git a/tests/unit/module_utils/botocore/test_is_boto3_error_code.py b/tests/unit/module_utils/botocore/test_is_boto3_error_code.py index ad2b111ca9..9f3e4194b7 100644 --- a/tests/unit/module_utils/botocore/test_is_boto3_error_code.py +++ b/tests/unit/module_utils/botocore/test_is_boto3_error_code.py @@ -12,8 +12,8 @@ # Handled by HAS_BOTO3 pass -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3 +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_code if not HAS_BOTO3: pytestmark = pytest.mark.skip("test_is_boto3_error_code.py requires the python modules 'boto3' and 'botocore'") diff --git a/tests/unit/module_utils/botocore/test_is_boto3_error_message.py b/tests/unit/module_utils/botocore/test_is_boto3_error_message.py index 6085c4b71b..9cfc62d172 100644 --- a/tests/unit/module_utils/botocore/test_is_boto3_error_message.py +++ b/tests/unit/module_utils/botocore/test_is_boto3_error_message.py @@ -12,8 +12,8 @@ # Handled by HAS_BOTO3 pass -from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_message from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3 +from ansible_collections.amazon.aws.plugins.module_utils.botocore import is_boto3_error_message if not HAS_BOTO3: pytestmark = pytest.mark.skip("test_is_boto3_error_message.py requires the python modules 'boto3' and 'botocore'") diff --git a/tests/unit/module_utils/botocore/test_merge_botocore_config.py b/tests/unit/module_utils/botocore/test_merge_botocore_config.py index 2776e971c4..f5a8710cd3 100644 --- a/tests/unit/module_utils/botocore/test_merge_botocore_config.py +++ b/tests/unit/module_utils/botocore/test_merge_botocore_config.py @@ -3,9 +3,10 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest from unittest.mock import MagicMock +import pytest + try: import botocore except ImportError: diff --git a/tests/unit/module_utils/botocore/test_sdk_versions.py b/tests/unit/module_utils/botocore/test_sdk_versions.py index 416fa85627..7e2877b6b5 100644 --- a/tests/unit/module_utils/botocore/test_sdk_versions.py +++ b/tests/unit/module_utils/botocore/test_sdk_versions.py @@ -3,25 +3,24 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest import warnings from unittest.mock import sentinel +import pytest + try: - import botocore import boto3 + import botocore except ImportError: # Handled by HAS_BOTO3 pass +from ansible_collections.amazon.aws.plugins.module_utils import botocore as botocore_utils from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3 -from ansible_collections.amazon.aws.plugins.module_utils.botocore import botocore_at_least from ansible_collections.amazon.aws.plugins.module_utils.botocore import boto3_at_least - +from ansible_collections.amazon.aws.plugins.module_utils.botocore import botocore_at_least from ansible_collections.amazon.aws.plugins.module_utils.exceptions import AnsibleBotocoreError -from ansible_collections.amazon.aws.plugins.module_utils import botocore as botocore_utils - DUMMY_VERSION = "5.5.5.5" TEST_VERSIONS = [ diff --git a/tests/unit/module_utils/cloud/test_cloud_retry.py b/tests/unit/module_utils/cloud/test_cloud_retry.py index 9feba78c58..06119d7f66 100644 --- a/tests/unit/module_utils/cloud/test_cloud_retry.py +++ b/tests/unit/module_utils/cloud/test_cloud_retry.py @@ -5,6 +5,7 @@ import random from datetime import datetime + import pytest from ansible_collections.amazon.aws.plugins.module_utils.cloud import CloudRetry diff --git a/tests/unit/module_utils/cloud/test_decorator_generation.py b/tests/unit/module_utils/cloud/test_decorator_generation.py index 4c860dea9e..ad38905037 100644 --- a/tests/unit/module_utils/cloud/test_decorator_generation.py +++ b/tests/unit/module_utils/cloud/test_decorator_generation.py @@ -3,13 +3,14 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest import sys from unittest.mock import MagicMock from unittest.mock import sentinel -from ansible_collections.amazon.aws.plugins.module_utils.cloud import CloudRetry +import pytest + from ansible_collections.amazon.aws.plugins.module_utils.cloud import BackoffIterator +from ansible_collections.amazon.aws.plugins.module_utils.cloud import CloudRetry if sys.version_info < (3, 8): pytest.skip( diff --git a/tests/unit/module_utils/cloud/test_retry_func.py b/tests/unit/module_utils/cloud/test_retry_func.py index 11ccf02fed..c318f61860 100644 --- a/tests/unit/module_utils/cloud/test_retry_func.py +++ b/tests/unit/module_utils/cloud/test_retry_func.py @@ -3,11 +3,12 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest import sys from unittest.mock import Mock from unittest.mock import sentinel +import pytest + import ansible_collections.amazon.aws.plugins.module_utils.cloud as cloud_utils if sys.version_info < (3, 8): diff --git a/tests/unit/module_utils/conftest.py b/tests/unit/module_utils/conftest.py index dd349dc288..397dfac844 100644 --- a/tests/unit/module_utils/conftest.py +++ b/tests/unit/module_utils/conftest.py @@ -3,16 +3,17 @@ import json import sys -from io import BytesIO import warnings +from io import BytesIO import pytest import ansible.module_utils.basic import ansible.module_utils.common -from ansible.module_utils.six import PY3, string_types from ansible.module_utils._text import to_bytes from ansible.module_utils.common._collections_compat import MutableMapping +from ansible.module_utils.six import PY3 +from ansible.module_utils.six import string_types @pytest.fixture diff --git a/tests/unit/module_utils/exceptions/test_exceptions.py b/tests/unit/module_utils/exceptions/test_exceptions.py index c7de2fce80..a2979f8485 100644 --- a/tests/unit/module_utils/exceptions/test_exceptions.py +++ b/tests/unit/module_utils/exceptions/test_exceptions.py @@ -3,9 +3,10 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest from unittest.mock import sentinel +import pytest + import ansible_collections.amazon.aws.plugins.module_utils.exceptions as aws_exceptions diff --git a/tests/unit/module_utils/modules/ansible_aws_module/test_fail_json_aws.py b/tests/unit/module_utils/modules/ansible_aws_module/test_fail_json_aws.py index c044068540..8a6fc96eca 100644 --- a/tests/unit/module_utils/modules/ansible_aws_module/test_fail_json_aws.py +++ b/tests/unit/module_utils/modules/ansible_aws_module/test_fail_json_aws.py @@ -4,11 +4,12 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) import json + import pytest try: - import botocore import boto3 + import botocore except ImportError: pass diff --git a/tests/unit/module_utils/modules/ansible_aws_module/test_minimal_versions.py b/tests/unit/module_utils/modules/ansible_aws_module/test_minimal_versions.py index 15aa71eae9..32210054b9 100644 --- a/tests/unit/module_utils/modules/ansible_aws_module/test_minimal_versions.py +++ b/tests/unit/module_utils/modules/ansible_aws_module/test_minimal_versions.py @@ -3,13 +3,14 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +import json from pprint import pprint + import pytest -import json try: - import botocore import boto3 + import botocore except ImportError: pass diff --git a/tests/unit/module_utils/modules/ansible_aws_module/test_passthrough.py b/tests/unit/module_utils/modules/ansible_aws_module/test_passthrough.py index 9d242dc70c..c61de13915 100644 --- a/tests/unit/module_utils/modules/ansible_aws_module/test_passthrough.py +++ b/tests/unit/module_utils/modules/ansible_aws_module/test_passthrough.py @@ -3,11 +3,12 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest -from unittest.mock import call +import warnings from unittest.mock import MagicMock +from unittest.mock import call from unittest.mock import sentinel -import warnings + +import pytest import ansible_collections.amazon.aws.plugins.module_utils.modules as utils_module diff --git a/tests/unit/module_utils/modules/ansible_aws_module/test_require_at_least.py b/tests/unit/module_utils/modules/ansible_aws_module/test_require_at_least.py index 741f340657..c383a42674 100644 --- a/tests/unit/module_utils/modules/ansible_aws_module/test_require_at_least.py +++ b/tests/unit/module_utils/modules/ansible_aws_module/test_require_at_least.py @@ -4,11 +4,12 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) import json + import pytest try: - import botocore import boto3 + import botocore except ImportError: # Handled by HAS_BOTO3 pass diff --git a/tests/unit/module_utils/policy/test_canonicalize.py b/tests/unit/module_utils/policy/test_canonicalize.py index 39c06aeea7..1206498286 100644 --- a/tests/unit/module_utils/policy/test_canonicalize.py +++ b/tests/unit/module_utils/policy/test_canonicalize.py @@ -5,8 +5,8 @@ from unittest.mock import sentinel -from ansible_collections.amazon.aws.plugins.module_utils.policy import _canonify_root_arn from ansible_collections.amazon.aws.plugins.module_utils.policy import _canonify_policy_dict_item +from ansible_collections.amazon.aws.plugins.module_utils.policy import _canonify_root_arn from ansible_collections.amazon.aws.plugins.module_utils.policy import _tuplify_list diff --git a/tests/unit/module_utils/retries/test_awsretry.py b/tests/unit/module_utils/retries/test_awsretry.py index b08ae23f1d..6141149ea1 100644 --- a/tests/unit/module_utils/retries/test_awsretry.py +++ b/tests/unit/module_utils/retries/test_awsretry.py @@ -11,8 +11,8 @@ import pytest -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3 +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry if not HAS_BOTO3: pytestmark = pytest.mark.skip("test_awsretry.py requires the python modules 'boto3' and 'botocore'") diff --git a/tests/unit/module_utils/retries/test_retry_wrapper.py b/tests/unit/module_utils/retries/test_retry_wrapper.py index 2fccff575b..406e318260 100644 --- a/tests/unit/module_utils/retries/test_retry_wrapper.py +++ b/tests/unit/module_utils/retries/test_retry_wrapper.py @@ -3,18 +3,19 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest +from unittest.mock import MagicMock from unittest.mock import call from unittest.mock import sentinel -from unittest.mock import MagicMock + +import pytest try: import botocore except ImportError: pass -import ansible_collections.amazon.aws.plugins.module_utils.retries as util_retries import ansible_collections.amazon.aws.plugins.module_utils.botocore as util_botocore +import ansible_collections.amazon.aws.plugins.module_utils.retries as util_retries @pytest.fixture diff --git a/tests/unit/module_utils/test_acm.py b/tests/unit/module_utils/test_acm.py index 2669b594c3..c7971831f1 100644 --- a/tests/unit/module_utils/test_acm.py +++ b/tests/unit/module_utils/test_acm.py @@ -5,10 +5,11 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest import random -from unittest.mock import MagicMock from unittest.mock import ANY +from unittest.mock import MagicMock + +import pytest try: import botocore @@ -16,8 +17,8 @@ # Handled by HAS_BOTO3 pass -from ansible_collections.amazon.aws.plugins.module_utils.acm import ACMServiceManager, acm_catch_boto_exception - +from ansible_collections.amazon.aws.plugins.module_utils.acm import ACMServiceManager +from ansible_collections.amazon.aws.plugins.module_utils.acm import acm_catch_boto_exception MODULE_NAME = "ansible_collections.amazon.aws.plugins.module_utils.acm" diff --git a/tests/unit/module_utils/test_cloudfront_facts.py b/tests/unit/module_utils/test_cloudfront_facts.py index 8166e94573..774d6bb10b 100644 --- a/tests/unit/module_utils/test_cloudfront_facts.py +++ b/tests/unit/module_utils/test_cloudfront_facts.py @@ -13,13 +13,13 @@ # Handled by HAS_BOTO3 pass -from ansible_collections.amazon.aws.plugins.module_utils.cloudfront_facts import ( - CloudFrontFactsServiceManager, - CloudFrontFactsServiceManagerFailure, - cloudfront_facts_keyed_list_helper, -) -from unittest.mock import MagicMock, patch, call +from unittest.mock import MagicMock +from unittest.mock import call +from unittest.mock import patch +from ansible_collections.amazon.aws.plugins.module_utils.cloudfront_facts import CloudFrontFactsServiceManager +from ansible_collections.amazon.aws.plugins.module_utils.cloudfront_facts import CloudFrontFactsServiceManagerFailure +from ansible_collections.amazon.aws.plugins.module_utils.cloudfront_facts import cloudfront_facts_keyed_list_helper MODULE_NAME = "ansible_collections.amazon.aws.plugins.module_utils.cloudfront_facts" MOCK_CLOUDFRONT_FACTS_KEYED_LIST_HELPER = MODULE_NAME + ".cloudfront_facts_keyed_list_helper" diff --git a/tests/unit/module_utils/test_iam.py b/tests/unit/module_utils/test_iam.py index 44f8006475..c910732886 100644 --- a/tests/unit/module_utils/test_iam.py +++ b/tests/unit/module_utils/test_iam.py @@ -4,9 +4,10 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest from unittest.mock import MagicMock +import pytest + try: import botocore except ImportError: diff --git a/tests/unit/module_utils/test_rds.py b/tests/unit/module_utils/test_rds.py index eb90acca77..51a715151b 100644 --- a/tests/unit/module_utils/test_rds.py +++ b/tests/unit/module_utils/test_rds.py @@ -4,9 +4,10 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) import sys -import pytest from unittest.mock import MagicMock +import pytest + if sys.version_info < (3, 7): pytest.skip("contextlib.nullcontext was introduced in Python 3.7", allow_module_level=True) diff --git a/tests/unit/module_utils/test_s3.py b/tests/unit/module_utils/test_s3.py index d70c9bd1b7..3770064c5b 100644 --- a/tests/unit/module_utils/test_s3.py +++ b/tests/unit/module_utils/test_s3.py @@ -4,12 +4,15 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest import random import string +from unittest.mock import MagicMock +from unittest.mock import call +from unittest.mock import patch + +import pytest from ansible_collections.amazon.aws.plugins.module_utils import s3 -from unittest.mock import MagicMock, patch, call try: import botocore diff --git a/tests/unit/plugin_utils/base/test_plugin.py b/tests/unit/plugin_utils/base/test_plugin.py index 93007beb20..f374934fd2 100644 --- a/tests/unit/plugin_utils/base/test_plugin.py +++ b/tests/unit/plugin_utils/base/test_plugin.py @@ -3,11 +3,12 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest -from unittest.mock import call +import warnings from unittest.mock import MagicMock +from unittest.mock import call from unittest.mock import sentinel -import warnings + +import pytest from ansible.errors import AnsibleError diff --git a/tests/unit/plugin_utils/botocore/test_boto3_conn_plugin.py b/tests/unit/plugin_utils/botocore/test_boto3_conn_plugin.py index 19062b81aa..766257d3b0 100644 --- a/tests/unit/plugin_utils/botocore/test_boto3_conn_plugin.py +++ b/tests/unit/plugin_utils/botocore/test_boto3_conn_plugin.py @@ -8,10 +8,11 @@ except ImportError: pass -import pytest from unittest.mock import MagicMock -from unittest.mock import sentinel from unittest.mock import call +from unittest.mock import sentinel + +import pytest import ansible_collections.amazon.aws.plugins.plugin_utils.botocore as utils_botocore diff --git a/tests/unit/plugin_utils/botocore/test_get_aws_region.py b/tests/unit/plugin_utils/botocore/test_get_aws_region.py index 6a0d18222b..e3f18282e2 100644 --- a/tests/unit/plugin_utils/botocore/test_get_aws_region.py +++ b/tests/unit/plugin_utils/botocore/test_get_aws_region.py @@ -3,10 +3,11 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest from unittest.mock import MagicMock -from unittest.mock import sentinel from unittest.mock import call +from unittest.mock import sentinel + +import pytest import ansible_collections.amazon.aws.plugins.plugin_utils.botocore as utils_botocore from ansible_collections.amazon.aws.plugins.module_utils.exceptions import AnsibleBotocoreError diff --git a/tests/unit/plugin_utils/botocore/test_get_connection_info.py b/tests/unit/plugin_utils/botocore/test_get_connection_info.py index a0b1c3d9fd..95c3ae54f8 100644 --- a/tests/unit/plugin_utils/botocore/test_get_connection_info.py +++ b/tests/unit/plugin_utils/botocore/test_get_connection_info.py @@ -3,10 +3,11 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest from unittest.mock import MagicMock -from unittest.mock import sentinel from unittest.mock import call +from unittest.mock import sentinel + +import pytest import ansible_collections.amazon.aws.plugins.plugin_utils.botocore as utils_botocore from ansible_collections.amazon.aws.plugins.module_utils.exceptions import AnsibleBotocoreError diff --git a/tests/unit/plugin_utils/connection/test_connection_base.py b/tests/unit/plugin_utils/connection/test_connection_base.py index f03b7cc8b7..8708cf045f 100644 --- a/tests/unit/plugin_utils/connection/test_connection_base.py +++ b/tests/unit/plugin_utils/connection/test_connection_base.py @@ -3,11 +3,12 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest -from unittest.mock import call from unittest.mock import MagicMock +from unittest.mock import call from unittest.mock import sentinel +import pytest + from ansible.errors import AnsibleConnectionFailure import ansible_collections.amazon.aws.plugins.plugin_utils.connection as utils_connection diff --git a/tests/unit/plugin_utils/inventory/test_inventory_base.py b/tests/unit/plugin_utils/inventory/test_inventory_base.py index 7d180e6e40..32eb3f7abf 100644 --- a/tests/unit/plugin_utils/inventory/test_inventory_base.py +++ b/tests/unit/plugin_utils/inventory/test_inventory_base.py @@ -3,13 +3,15 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest -from unittest.mock import call from unittest.mock import MagicMock +from unittest.mock import call from unittest.mock import patch from unittest.mock import sentinel +import pytest + import ansible.plugins.inventory as base_inventory + import ansible_collections.amazon.aws.plugins.plugin_utils.inventory as utils_inventory diff --git a/tests/unit/plugin_utils/inventory/test_inventory_clients.py b/tests/unit/plugin_utils/inventory/test_inventory_clients.py index 22a9f4014a..82831ac565 100644 --- a/tests/unit/plugin_utils/inventory/test_inventory_clients.py +++ b/tests/unit/plugin_utils/inventory/test_inventory_clients.py @@ -3,12 +3,12 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -from unittest.mock import call from unittest.mock import MagicMock +from unittest.mock import call from unittest.mock import sentinel -import ansible_collections.amazon.aws.plugins.plugin_utils.inventory as utils_inventory import ansible_collections.amazon.aws.plugins.plugin_utils.base as utils_base +import ansible_collections.amazon.aws.plugins.plugin_utils.inventory as utils_inventory # import ansible_collections.amazon.aws.plugins.module_utils. diff --git a/tests/unit/plugin_utils/lookup/test_lookup_base.py b/tests/unit/plugin_utils/lookup/test_lookup_base.py index 2ba27911d1..7e90ecdeb1 100644 --- a/tests/unit/plugin_utils/lookup/test_lookup_base.py +++ b/tests/unit/plugin_utils/lookup/test_lookup_base.py @@ -3,11 +3,12 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest -from unittest.mock import call from unittest.mock import MagicMock +from unittest.mock import call from unittest.mock import sentinel +import pytest + from ansible.errors import AnsibleLookupError import ansible_collections.amazon.aws.plugins.plugin_utils.lookup as utils_lookup diff --git a/tests/unit/plugins/inventory/test_aws_ec2.py b/tests/unit/plugins/inventory/test_aws_ec2.py index 72da05a1fc..d136880c3b 100644 --- a/tests/unit/plugins/inventory/test_aws_ec2.py +++ b/tests/unit/plugins/inventory/test_aws_ec2.py @@ -17,8 +17,11 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from unittest.mock import MagicMock +from unittest.mock import call +from unittest.mock import patch + import pytest -from unittest.mock import MagicMock, patch, call try: import botocore @@ -27,13 +30,12 @@ pass from ansible.errors import AnsibleError -from ansible_collections.amazon.aws.plugins.inventory.aws_ec2 import ( - InventoryModule, - _get_tag_hostname, - _prepare_host_vars, - _compile_values, - _get_boto_attr_chain, -) + +from ansible_collections.amazon.aws.plugins.inventory.aws_ec2 import InventoryModule +from ansible_collections.amazon.aws.plugins.inventory.aws_ec2 import _compile_values +from ansible_collections.amazon.aws.plugins.inventory.aws_ec2 import _get_boto_attr_chain +from ansible_collections.amazon.aws.plugins.inventory.aws_ec2 import _get_tag_hostname +from ansible_collections.amazon.aws.plugins.inventory.aws_ec2 import _prepare_host_vars @pytest.fixture() diff --git a/tests/unit/plugins/inventory/test_aws_rds.py b/tests/unit/plugins/inventory/test_aws_rds.py index 96ca05bb8c..53be24a484 100644 --- a/tests/unit/plugins/inventory/test_aws_rds.py +++ b/tests/unit/plugins/inventory/test_aws_rds.py @@ -18,13 +18,14 @@ # along with Ansible. If not, see . import copy -import pytest import random import string from unittest.mock import MagicMock from unittest.mock import call from unittest.mock import patch +import pytest + try: import botocore except ImportError: @@ -32,17 +33,15 @@ pass from ansible.errors import AnsibleError -from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3 -from ansible_collections.amazon.aws.plugins.inventory.aws_rds import ( - InventoryModule, - _find_hosts_with_valid_statuses, - _get_rds_hostname, - _add_tags_for_rds_hosts, - _describe_db_clusters, - _describe_db_instances, - ansible_dict_to_boto3_filter_list, -) +from ansible_collections.amazon.aws.plugins.inventory.aws_rds import InventoryModule +from ansible_collections.amazon.aws.plugins.inventory.aws_rds import _add_tags_for_rds_hosts +from ansible_collections.amazon.aws.plugins.inventory.aws_rds import _describe_db_clusters +from ansible_collections.amazon.aws.plugins.inventory.aws_rds import _describe_db_instances +from ansible_collections.amazon.aws.plugins.inventory.aws_rds import _find_hosts_with_valid_statuses +from ansible_collections.amazon.aws.plugins.inventory.aws_rds import _get_rds_hostname +from ansible_collections.amazon.aws.plugins.inventory.aws_rds import ansible_dict_to_boto3_filter_list +from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3 if not HAS_BOTO3: pytestmark = pytest.mark.skip("test_aws_rds.py requires the python modules 'boto3' and 'botocore'") diff --git a/tests/unit/plugins/modules/conftest.py b/tests/unit/plugins/modules/conftest.py index 166eaf7d3d..7a870163c1 100644 --- a/tests/unit/plugins/modules/conftest.py +++ b/tests/unit/plugins/modules/conftest.py @@ -5,9 +5,9 @@ import pytest -from ansible.module_utils.six import string_types from ansible.module_utils._text import to_bytes from ansible.module_utils.common._collections_compat import MutableMapping +from ansible.module_utils.six import string_types @pytest.fixture diff --git a/tests/unit/plugins/modules/ec2_instance/test_build_run_instance_spec.py b/tests/unit/plugins/modules/ec2_instance/test_build_run_instance_spec.py index fdfbf13e75..a64c169616 100644 --- a/tests/unit/plugins/modules/ec2_instance/test_build_run_instance_spec.py +++ b/tests/unit/plugins/modules/ec2_instance/test_build_run_instance_spec.py @@ -3,9 +3,10 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest from unittest.mock import sentinel +import pytest + import ansible_collections.amazon.aws.plugins.modules.ec2_instance as ec2_instance_module diff --git a/tests/unit/plugins/modules/ec2_instance/test_determine_iam_role.py b/tests/unit/plugins/modules/ec2_instance/test_determine_iam_role.py index 0bd9a284e8..7645d55595 100644 --- a/tests/unit/plugins/modules/ec2_instance/test_determine_iam_role.py +++ b/tests/unit/plugins/modules/ec2_instance/test_determine_iam_role.py @@ -3,13 +3,14 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest import sys from unittest.mock import MagicMock from unittest.mock import sentinel -import ansible_collections.amazon.aws.plugins.modules.ec2_instance as ec2_instance_module +import pytest + import ansible_collections.amazon.aws.plugins.module_utils.arn as utils_arn +import ansible_collections.amazon.aws.plugins.modules.ec2_instance as ec2_instance_module from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3 try: diff --git a/tests/unit/plugins/modules/ec2_security_group/test_expand_rules.py b/tests/unit/plugins/modules/ec2_security_group/test_expand_rules.py index 9c89f847ce..1abfd526cd 100644 --- a/tests/unit/plugins/modules/ec2_security_group/test_expand_rules.py +++ b/tests/unit/plugins/modules/ec2_security_group/test_expand_rules.py @@ -3,10 +3,11 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest import sys from unittest.mock import sentinel +import pytest + import ansible_collections.amazon.aws.plugins.modules.ec2_security_group as ec2_security_group_module PORT_EXPANSION = [ diff --git a/tests/unit/plugins/modules/ec2_security_group/test_formatting.py b/tests/unit/plugins/modules/ec2_security_group/test_formatting.py index 4521a6508c..358512a008 100644 --- a/tests/unit/plugins/modules/ec2_security_group/test_formatting.py +++ b/tests/unit/plugins/modules/ec2_security_group/test_formatting.py @@ -3,9 +3,10 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest from unittest.mock import sentinel +import pytest + import ansible_collections.amazon.aws.plugins.modules.ec2_security_group as ec2_security_group_module SORT_ORDER = [ diff --git a/tests/unit/plugins/modules/ec2_security_group/test_get_target_from_rule.py b/tests/unit/plugins/modules/ec2_security_group/test_get_target_from_rule.py index 98e5f8b5c7..34fa8de1a4 100644 --- a/tests/unit/plugins/modules/ec2_security_group/test_get_target_from_rule.py +++ b/tests/unit/plugins/modules/ec2_security_group/test_get_target_from_rule.py @@ -4,9 +4,10 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from copy import deepcopy -import pytest from unittest.mock import sentinel +import pytest + import ansible_collections.amazon.aws.plugins.modules.ec2_security_group as ec2_security_group_module diff --git a/tests/unit/plugins/modules/ec2_security_group/test_validate_ip.py b/tests/unit/plugins/modules/ec2_security_group/test_validate_ip.py index c3473aa53a..eb2de75961 100644 --- a/tests/unit/plugins/modules/ec2_security_group/test_validate_ip.py +++ b/tests/unit/plugins/modules/ec2_security_group/test_validate_ip.py @@ -3,10 +3,11 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest +import warnings from unittest.mock import MagicMock from unittest.mock import sentinel -import warnings + +import pytest import ansible_collections.amazon.aws.plugins.modules.ec2_security_group as ec2_security_group_module diff --git a/tests/unit/plugins/modules/ec2_security_group/test_validate_rule.py b/tests/unit/plugins/modules/ec2_security_group/test_validate_rule.py index 34d4f45f77..9949c1b5cc 100644 --- a/tests/unit/plugins/modules/ec2_security_group/test_validate_rule.py +++ b/tests/unit/plugins/modules/ec2_security_group/test_validate_rule.py @@ -4,11 +4,11 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from copy import deepcopy + import pytest import ansible_collections.amazon.aws.plugins.modules.ec2_security_group as ec2_security_group_module - VALID_RULES = [ dict( proto="all", diff --git a/tests/unit/plugins/modules/test_backup_restore_job_info.py b/tests/unit/plugins/modules/test_backup_restore_job_info.py index 3f46074ed9..51c495e30c 100644 --- a/tests/unit/plugins/modules/test_backup_restore_job_info.py +++ b/tests/unit/plugins/modules/test_backup_restore_job_info.py @@ -3,11 +3,13 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest from unittest.mock import MagicMock from unittest.mock import patch +import pytest + from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + from ansible_collections.amazon.aws.plugins.modules import backup_restore_job_info module_name = "ansible_collections.amazon.aws.plugins.modules.backup_restore_job_info" diff --git a/tests/unit/plugins/modules/test_cloudformation.py b/tests/unit/plugins/modules/test_cloudformation.py index 8fbefebbf8..475969b24b 100644 --- a/tests/unit/plugins/modules/test_cloudformation.py +++ b/tests/unit/plugins/modules/test_cloudformation.py @@ -5,19 +5,17 @@ import pytest +from ansible_collections.amazon.aws.plugins.module_utils.botocore import boto_exception +from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.retries import RetryingBotoClientWrapper +from ansible_collections.amazon.aws.plugins.modules import cloudformation as cfn_module + +# pylint: disable-next=unused-import # Magic... # pylint: disable-next=unused-import from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import maybe_sleep - -# pylint: disable-next=unused-import from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify -from ansible_collections.amazon.aws.plugins.module_utils.botocore import boto_exception -from ansible_collections.amazon.aws.plugins.module_utils.retries import RetryingBotoClientWrapper -from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry - -from ansible_collections.amazon.aws.plugins.modules import cloudformation as cfn_module - basic_yaml_tpl = """ --- AWSTemplateFormatVersion: '2010-09-09' diff --git a/tests/unit/plugins/modules/test_ec2_ami.py b/tests/unit/plugins/modules/test_ec2_ami.py index 2ac59d9c42..b1e23451ba 100644 --- a/tests/unit/plugins/modules/test_ec2_ami.py +++ b/tests/unit/plugins/modules/test_ec2_ami.py @@ -2,8 +2,8 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from unittest.mock import MagicMock -from unittest.mock import patch from unittest.mock import call +from unittest.mock import patch import pytest diff --git a/tests/unit/plugins/modules/test_ec2_ami_info.py b/tests/unit/plugins/modules/test_ec2_ami_info.py index 797e29004a..c33553ee55 100644 --- a/tests/unit/plugins/modules/test_ec2_ami_info.py +++ b/tests/unit/plugins/modules/test_ec2_ami_info.py @@ -3,11 +3,16 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict -from unittest.mock import MagicMock, patch, ANY, call +from unittest.mock import ANY +from unittest.mock import MagicMock +from unittest.mock import call +from unittest.mock import patch + import botocore.exceptions import pytest +from ansible.module_utils.common.dict_transformations import camel_dict_to_snake_dict + from ansible_collections.amazon.aws.plugins.modules import ec2_ami_info module_name = "ansible_collections.amazon.aws.plugins.modules.ec2_ami_info" diff --git a/tests/unit/plugins/modules/test_ec2_eni_info.py b/tests/unit/plugins/modules/test_ec2_eni_info.py index f825bffa8a..d6323601dc 100644 --- a/tests/unit/plugins/modules/test_ec2_eni_info.py +++ b/tests/unit/plugins/modules/test_ec2_eni_info.py @@ -3,11 +3,12 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest from unittest.mock import MagicMock from unittest.mock import call from unittest.mock import patch +import pytest + from ansible_collections.amazon.aws.plugins.modules import ec2_eni_info module_name = "ansible_collections.amazon.aws.plugins.modules.ec2_eni_info" diff --git a/tests/unit/plugins/modules/test_ec2_key.py b/tests/unit/plugins/modules/test_ec2_key.py index de5e45a362..cbcf025881 100644 --- a/tests/unit/plugins/modules/test_ec2_key.py +++ b/tests/unit/plugins/modules/test_ec2_key.py @@ -1,15 +1,15 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +import copy import datetime -from dateutil.tz import tzutc -import pytest +from unittest.mock import ANY from unittest.mock import MagicMock from unittest.mock import patch -from unittest.mock import ANY import botocore -import copy +import pytest +from dateutil.tz import tzutc from ansible.module_utils._text import to_bytes diff --git a/tests/unit/plugins/modules/test_ec2_metadata_facts.py b/tests/unit/plugins/modules/test_ec2_metadata_facts.py index 10c4a341ad..23ba850030 100644 --- a/tests/unit/plugins/modules/test_ec2_metadata_facts.py +++ b/tests/unit/plugins/modules/test_ec2_metadata_facts.py @@ -3,10 +3,11 @@ import gzip import io -import pytest from unittest.mock import MagicMock from unittest.mock import patch +import pytest + from ansible_collections.amazon.aws.plugins.modules import ec2_metadata_facts module_name = "ansible_collections.amazon.aws.plugins.modules.ec2_metadata_facts" diff --git a/tests/unit/plugins/modules/test_ec2_snapshot_info.py b/tests/unit/plugins/modules/test_ec2_snapshot_info.py index 8bc493baf4..34767d38ac 100644 --- a/tests/unit/plugins/modules/test_ec2_snapshot_info.py +++ b/tests/unit/plugins/modules/test_ec2_snapshot_info.py @@ -3,11 +3,12 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest -from unittest.mock import MagicMock -from unittest.mock import patch from unittest.mock import ANY +from unittest.mock import MagicMock from unittest.mock import call +from unittest.mock import patch + +import pytest from ansible_collections.amazon.aws.plugins.modules import ec2_snapshot_info diff --git a/tests/unit/plugins/modules/test_ec2_vpc_dhcp_option.py b/tests/unit/plugins/modules/test_ec2_vpc_dhcp_option.py index 7118bd9157..27517115e1 100644 --- a/tests/unit/plugins/modules/test_ec2_vpc_dhcp_option.py +++ b/tests/unit/plugins/modules/test_ec2_vpc_dhcp_option.py @@ -5,13 +5,13 @@ from unittest.mock import patch +from ansible_collections.amazon.aws.plugins.modules import ec2_vpc_dhcp_option as dhcp_module +from ansible_collections.amazon.aws.tests.unit.plugins.modules.utils import ModuleTestCase + # Magic... Incorrectly identified by pylint as unused # pylint: disable-next=unused-import from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify -from ansible_collections.amazon.aws.plugins.modules import ec2_vpc_dhcp_option as dhcp_module -from ansible_collections.amazon.aws.tests.unit.plugins.modules.utils import ModuleTestCase - test_module_params = { "domain_name": "us-west-2.compute.internal", "dns_servers": ["AmazonProvidedDNS"], diff --git a/tests/unit/plugins/modules/test_kms_key.py b/tests/unit/plugins/modules/test_kms_key.py index 93565d3414..b2d8e0b50b 100644 --- a/tests/unit/plugins/modules/test_kms_key.py +++ b/tests/unit/plugins/modules/test_kms_key.py @@ -9,7 +9,6 @@ from ansible_collections.amazon.aws.plugins.modules import kms_key - module_name = "ansible_collections.amazon.aws.plugins.modules.kms_key" key_details = { "KeyMetadata": { diff --git a/tests/unit/plugins/modules/test_lambda_layer.py b/tests/unit/plugins/modules/test_lambda_layer.py index c241c6c82c..cd3032ef7e 100644 --- a/tests/unit/plugins/modules/test_lambda_layer.py +++ b/tests/unit/plugins/modules/test_lambda_layer.py @@ -4,9 +4,12 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from unittest.mock import MagicMock +from unittest.mock import call +from unittest.mock import patch + import pytest -from unittest.mock import MagicMock, call, patch from ansible_collections.amazon.aws.plugins.modules import lambda_layer diff --git a/tests/unit/plugins/modules/test_lambda_layer_info.py b/tests/unit/plugins/modules/test_lambda_layer_info.py index a6fa09ed96..2016254011 100644 --- a/tests/unit/plugins/modules/test_lambda_layer_info.py +++ b/tests/unit/plugins/modules/test_lambda_layer_info.py @@ -4,13 +4,15 @@ # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from unittest.mock import MagicMock +from unittest.mock import call +from unittest.mock import patch + import pytest from botocore.exceptions import BotoCoreError -from unittest.mock import MagicMock, call, patch from ansible_collections.amazon.aws.plugins.modules import lambda_layer_info - mod__list_layer_versions = "ansible_collections.amazon.aws.plugins.modules.lambda_layer_info._list_layer_versions" mod__list_layers = "ansible_collections.amazon.aws.plugins.modules.lambda_layer_info._list_layers" mod_list_layer_versions = "ansible_collections.amazon.aws.plugins.modules.lambda_layer_info.list_layer_versions" diff --git a/tests/unit/plugins/modules/test_rds_instance_info.py b/tests/unit/plugins/modules/test_rds_instance_info.py index 8f881f8101..8db20f1a07 100644 --- a/tests/unit/plugins/modules/test_rds_instance_info.py +++ b/tests/unit/plugins/modules/test_rds_instance_info.py @@ -2,13 +2,13 @@ # # This file is part of Ansible # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -import pytest -from unittest.mock import MagicMock -from unittest.mock import patch from unittest.mock import ANY +from unittest.mock import MagicMock from unittest.mock import call +from unittest.mock import patch import botocore.exceptions +import pytest from ansible_collections.amazon.aws.plugins.modules import rds_instance_info diff --git a/tests/unit/plugins/modules/test_s3_object.py b/tests/unit/plugins/modules/test_s3_object.py index 863001335a..deeb1c4a0c 100644 --- a/tests/unit/plugins/modules/test_s3_object.py +++ b/tests/unit/plugins/modules/test_s3_object.py @@ -5,9 +5,9 @@ from unittest.mock import MagicMock from unittest.mock import patch -import pytest import botocore.exceptions +import pytest from ansible_collections.amazon.aws.plugins.modules import s3_object diff --git a/tests/unit/utils/amazon_placebo_fixtures.py b/tests/unit/utils/amazon_placebo_fixtures.py index 3e06f97eb8..afe91adad4 100644 --- a/tests/unit/utils/amazon_placebo_fixtures.py +++ b/tests/unit/utils/amazon_placebo_fixtures.py @@ -1,10 +1,13 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function __metaclass__ = type import errno import os import time + import mock import pytest