diff --git a/changelogs/fragments/migrate_aws_region_info.yml b/changelogs/fragments/migrate_aws_region_info.yml new file mode 100644 index 00000000000..ba6b319168f --- /dev/null +++ b/changelogs/fragments/migrate_aws_region_info.yml @@ -0,0 +1,5 @@ +--- +breaking_changes: + - aws_region_info - The module has been migrated from the ``community.aws`` collection. + Playbooks using the Fully Qualified Collection Name for this module should be + updated to use ``amazon.aws.aws_region_info``. diff --git a/meta/runtime.yml b/meta/runtime.yml index d51c34ba130..93e6c44ab53 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -47,7 +47,6 @@ action_groups: - aws_inspector_target - aws_msk_cluster - aws_msk_config - - aws_region_info - aws_s3_bucket_info - aws_s3_cors - aws_secret @@ -322,6 +321,8 @@ plugin_routing: aws_msk_config: # Deprecation for this alias should not *start* prior to 2024-09-01 redirect: community.aws.msk_config + aws_region_info: + redirect: amazon.aws.aws_region_info aws_s3_bucket_info: # Deprecation for this alias should not *start* prior to 2024-09-01 redirect: community.aws.s3_bucket_info @@ -514,4 +515,4 @@ plugin_routing: redirect: amazon.aws.iam_managed_policy module_utils: route53: - redirect: amazon.aws.route53 + redirect: amazon.aws.route53 \ No newline at end of file diff --git a/plugins/modules/aws_region_info.py b/plugins/modules/aws_region_info.py deleted file mode 100644 index a268c13b3c8..00000000000 --- a/plugins/modules/aws_region_info.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright (c) 2017 Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -DOCUMENTATION = r""" -module: aws_region_info -short_description: Gather information about AWS regions -version_added: 1.0.0 -description: - - Gather information about AWS regions. -author: - - 'Henrique Rodrigues (@Sodki)' -options: - filters: - description: - - A dict of filters to apply. - - Each dict item consists of a filter key and a filter value. - - See U(https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeRegions.html) for possible filters. - - Filter names and values are case sensitive. - - You can use underscores instead of dashes (-) in the filter keys. - - Filter keys with underscores will take precedence in case of conflict. - default: {} - type: dict -extends_documentation_fragment: - - amazon.aws.common.modules - - amazon.aws.region.modules - - amazon.aws.boto3 -""" - -EXAMPLES = r""" -# Note: These examples do not set authentication details, see the AWS Guide for details. - -# Gather information about all regions -- community.aws.aws_region_info: - -# Gather information about a single region -- community.aws.aws_region_info: - filters: - region-name: eu-west-1 -""" - -RETURN = r""" -regions: - returned: on success - description: > - Regions that match the provided filters. Each element consists of a dict with all the information related - to that region. - type: list - sample: "[{ - 'endpoint': 'ec2.us-west-1.amazonaws.com', - 'region_name': 'us-west-1' - }]" -""" - -try: - 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.retries import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.transformation import ansible_dict_to_boto3_filter_list - -from ansible_collections.community.aws.plugins.module_utils.modules import AnsibleCommunityAWSModule as AnsibleAWSModule - - -def main(): - argument_spec = dict( - filters=dict(default={}, type="dict"), - ) - - module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) - - connection = module.client("ec2", retry_decorator=AWSRetry.jittered_backoff()) - - # Replace filter key underscores with dashes, for compatibility - sanitized_filters = dict(module.params.get("filters")) - for k in module.params.get("filters").keys(): - if "_" in k: - sanitized_filters[k.replace("_", "-")] = sanitized_filters[k] - del sanitized_filters[k] - - try: - regions = connection.describe_regions( - aws_retry=True, Filters=ansible_dict_to_boto3_filter_list(sanitized_filters) - ) - except (BotoCoreError, ClientError) as e: - module.fail_json_aws(e, msg="Unable to describe regions.") - - module.exit_json(regions=[camel_dict_to_snake_dict(r) for r in regions["Regions"]]) - - -if __name__ == "__main__": - main() diff --git a/tests/integration/targets/aws_region_info/aliases b/tests/integration/targets/aws_region_info/aliases deleted file mode 100644 index 4ef4b2067d0..00000000000 --- a/tests/integration/targets/aws_region_info/aliases +++ /dev/null @@ -1 +0,0 @@ -cloud/aws diff --git a/tests/integration/targets/aws_region_info/main.yml b/tests/integration/targets/aws_region_info/main.yml deleted file mode 100644 index abffda9161e..00000000000 --- a/tests/integration/targets/aws_region_info/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -- hosts: localhost - connection: local - environment: "{{ ansible_test.environment }}" - tasks: - - include_tasks: 'tasks/tests.yml' diff --git a/tests/integration/targets/aws_region_info/meta/main.yml b/tests/integration/targets/aws_region_info/meta/main.yml deleted file mode 100644 index 32cf5dda7ed..00000000000 --- a/tests/integration/targets/aws_region_info/meta/main.yml +++ /dev/null @@ -1 +0,0 @@ -dependencies: [] diff --git a/tests/integration/targets/aws_region_info/tasks/main.yml b/tests/integration/targets/aws_region_info/tasks/main.yml deleted file mode 100644 index 4391bd242ef..00000000000 --- a/tests/integration/targets/aws_region_info/tasks/main.yml +++ /dev/null @@ -1,107 +0,0 @@ ---- -- module_defaults: - group/aws: - access_key: '{{ aws_access_key }}' - secret_key: '{{ aws_secret_key }}' - session_token: '{{ security_token | default(omit) }}' - region: '{{ aws_region }}' - - block: - - name: 'List available Regions' - aws_region_info: - register: regions - - - name: check task return attributes - vars: - first_region: '{{ regions.regions[0] }}' - assert: - that: - - regions is successful - - regions is not changed - - '"regions" in regions' - - '"endpoint" in first_region' - - '"opt_in_status" in first_region' - - '"region_name" in first_region' - - - name: 'List available Regions - check_mode' - aws_region_info: - register: check_regions - - - name: check task return attributes - check_mode - vars: - first_region: '{{ check_regions.regions[0] }}' - assert: - that: - - check_regions is successful - - check_regions is not changed - - '"regions" in check_regions' - - '"endpoint" in first_region' - - '"opt_in_status" in first_region' - - '"region_name" in first_region' - - - name: 'Filter available Regions using - ("region-name")' - aws_region_info: - filters: - region-name: 'us-west-1' - register: us_west_1 - - - name: check task return attributes - filtering using - - vars: - first_region: '{{ us_west_1.regions[0] }}' - assert: - that: - - us_west_1 is successful - - us_west_1 is not changed - - '"regions" in us_west_1' - - us_west_1.regions | length == 1 - - '"endpoint" in first_region' - - first_region.endpoint == 'ec2.us-west-1.amazonaws.com' - - '"opt_in_status" in first_region' - - first_region.opt_in_status == 'opt-in-not-required' - - '"region_name" in first_region' - - first_region.region_name == 'us-west-1' - - - name: 'Filter available Regions using _ ("region_name")' - aws_region_info: - filters: - region_name: 'us-west-2' - register: us_west_2 - - - name: check task return attributes - filtering using _ - vars: - first_region: '{{ us_west_2.regions[0] }}' - assert: - that: - - us_west_2 is successful - - us_west_2 is not changed - - '"regions" in us_west_2' - - us_west_2.regions | length == 1 - - '"endpoint" in first_region' - - first_region.endpoint == 'ec2.us-west-2.amazonaws.com' - - '"opt_in_status" in first_region' - - first_region.opt_in_status == 'opt-in-not-required' - - '"region_name" in first_region' - - first_region.region_name == 'us-west-2' - - - name: 'Filter available Regions using _ and - to check precedence' - aws_region_info: - filters: - region-name: 'eu-west-1' - region_name: 'eu-central-1' - register: regions_prededence - - - name: check task return attributes - precedence - vars: - first_region: '{{ regions_prededence.regions[0] }}' - assert: - that: - - regions_prededence is successful - - regions_prededence is not changed - - '"regions" in regions_prededence' - - regions_prededence.regions | length == 1 - - '"endpoint" in first_region' - - first_region.endpoint == 'ec2.eu-central-1.amazonaws.com' - - '"opt_in_status" in first_region' - - first_region.opt_in_status == 'opt-in-not-required' - - '"region_name" in first_region' - - first_region.region_name == 'eu-central-1'