From 67fe8a88db6a4b51d6a7eaffe5ec47283327d2dc Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Mon, 2 Jan 2023 16:27:46 +0100 Subject: [PATCH 1/3] [6.0.0] ec2_vpc_endpoint_info - Drop support for `query` --- plugins/modules/ec2_vpc_endpoint_info.py | 89 +++---------------- .../targets/ec2_vpc_endpoint/tasks/main.yml | 38 -------- 2 files changed, 12 insertions(+), 115 deletions(-) diff --git a/plugins/modules/ec2_vpc_endpoint_info.py b/plugins/modules/ec2_vpc_endpoint_info.py index b7773bf119b..ce03d1dbf12 100644 --- a/plugins/modules/ec2_vpc_endpoint_info.py +++ b/plugins/modules/ec2_vpc_endpoint_info.py @@ -8,19 +8,6 @@ description: - Gets various details related to AWS VPC endpoints. options: - query: - description: - - Defaults to C(endpoints). - - Specifies the query action to take. - - I(query=endpoints) returns information about AWS VPC endpoints. - - Retrieving information about services using I(query=services) has been - deprecated in favour of the M(amazon.aws.ec2_vpc_endpoint_service_info) module. - - The I(query) option has been deprecated and will be removed in release 6.0.0. - required: False - choices: - - services - - endpoints - type: str vpc_endpoint_ids: description: - The IDs of specific endpoints to retrieve the details of. @@ -33,30 +20,27 @@ for possible filters. type: dict default: {} -author: Karen Cheng (@Etherdaemon) +author: + - Karen Cheng (@Etherdaemon) extends_documentation_fragment: -- amazon.aws.aws -- amazon.aws.ec2 -- amazon.aws.boto3 + - amazon.aws.aws + - amazon.aws.ec2 + - amazon.aws.boto3 +notes: + - Support for the C(query) parameter was dropped in release 6.0.0. This module now only queries + for endpoints. Information about endpoint services can be retrieved using the + M(amazon.aws.ec2_vpc_endpoint_service_info) module. ''' EXAMPLES = r''' # Simple example of listing all support AWS services for VPC endpoints -- name: List supported AWS endpoint services - amazon.aws.ec2_vpc_endpoint_info: - query: services - region: ap-southeast-2 - register: supported_endpoint_services - - name: Get all endpoints in ap-southeast-2 region amazon.aws.ec2_vpc_endpoint_info: - query: endpoints region: ap-southeast-2 register: existing_endpoints - name: Get all endpoints with specific filters amazon.aws.ec2_vpc_endpoint_info: - query: endpoints region: ap-southeast-2 filters: vpc-id: @@ -69,7 +53,6 @@ - name: Get details on specific endpoint amazon.aws.ec2_vpc_endpoint_info: - query: endpoints region: ap-southeast-2 vpc_endpoint_ids: - vpce-12345678 @@ -77,19 +60,10 @@ ''' RETURN = r''' -service_names: - description: AWS VPC endpoint service names. - returned: I(query) is C(services) - type: list - elements: str - sample: - service_names: - - com.amazonaws.ap-southeast-2.s3 vpc_endpoints: description: - - A list of endpoints that match the query. Each endpoint has the keys creation_timestamp, - policy_document, route_table_ids, service_name, state, vpc_endpoint_id, vpc_id. - returned: I(query) is C(endpoints) + - A list of matching endpoints. + returned: always type: list elements: dict contains: @@ -215,22 +189,6 @@ def _describe_endpoints(client, **params): return paginator.paginate(**params).build_full_result() -@AWSRetry.jittered_backoff() -def _describe_endpoint_services(client, **params): - paginator = client.get_paginator('describe_vpc_endpoint_services') - return paginator.paginate(**params).build_full_result() - - -def get_supported_services(client, module): - try: - services = _describe_endpoint_services(client) - except (botocore.exceptions.BotoCoreError, botocore.exceptions.ClientError) as e: - module.fail_json_aws(e, msg="Failed to get endpoint servicess") - - results = list(services['ServiceNames']) - return dict(service_names=results) - - def get_endpoints(client, module): results = list() params = dict() @@ -250,7 +208,6 @@ def get_endpoints(client, module): def main(): argument_spec = dict( - query=dict(choices=['services', 'endpoints'], required=False), filters=dict(default={}, type='dict'), vpc_endpoint_ids=dict(type='list', elements='str'), ) @@ -263,29 +220,7 @@ def main(): except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: module.fail_json_aws(e, msg='Failed to connect to AWS') - query = module.params.get('query') - if query == 'endpoints': - module.deprecate('The query option has been deprecated and' - ' will be removed in release 6.0.0. Searching for' - ' `endpoints` is now the default and after' - ' release 6.0.0 this module will only support fetching' - ' endpoints.', - version='6.0.0', collection_name='amazon.aws') - elif query == 'services': - module.deprecate('Support for fetching service information with this ' - 'module has been deprecated and will be removed in ' - 'release 6.0.0. ' - 'Please use the ec2_vpc_endpoint_service_info module ' - 'instead.', version='6.0.0', - collection_name='amazon.aws') - else: - query = 'endpoints' - - invocations = { - 'services': get_supported_services, - 'endpoints': get_endpoints, - } - results = invocations[query](connection, module) + results = get_endpoints(connection, module) module.exit_json(**results) diff --git a/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml b/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml index 1f8c0881f82..4ea9e938cff 100644 --- a/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml @@ -72,7 +72,6 @@ # Minimal check_mode with _info - name: Fetch Endpoints in check_mode ec2_vpc_endpoint_info: - query: endpoints register: endpoint_info check_mode: true - name: Assert success @@ -84,37 +83,6 @@ - endpoint_info is successful - '"vpc_endpoints" in endpoint_info' - - name: Fetch Services in check_mode - ec2_vpc_endpoint_info: - query: services - register: endpoint_info - check_mode: true - - name: Assert success - assert: - that: - - endpoint_info is successful - - '"service_names" in endpoint_info' - # This is just 2 arbitrary AWS services that should (generally) be - # available. The actual list will vary over time and between regions - - endpoint_service_a in endpoint_info.service_names - - endpoint_service_b in endpoint_info.service_names - - # Fetch services without check mode - # Note: Filters not supported on services via this module, this is all we can test for now - - name: Fetch Services - ec2_vpc_endpoint_info: - query: services - register: endpoint_info - - name: Assert success - assert: - that: - - endpoint_info is successful - - '"service_names" in endpoint_info' - # This is just 2 arbitrary AWS services that should (generally) be - # available. The actual list will vary over time and between regions - - endpoint_service_a in endpoint_info.service_names - - endpoint_service_b in endpoint_info.service_names - # Attempt to create an endpoint - name: Create minimal endpoint (check mode) ec2_vpc_endpoint: @@ -168,7 +136,6 @@ # Pull info about the endpoints - name: Fetch Endpoints (all) ec2_vpc_endpoint_info: - query: endpoints register: endpoint_info - name: Assert success assert: @@ -203,7 +170,6 @@ - name: Fetch Endpoints (targetted by ID) ec2_vpc_endpoint_info: - query: endpoints vpc_endpoint_ids: '{{ endpoint_id }}' register: endpoint_info - name: Assert success @@ -240,7 +206,6 @@ - name: Fetch Endpoints (targetted by VPC) ec2_vpc_endpoint_info: - query: endpoints filters: vpc-id: - '{{ vpc_id }}' @@ -340,7 +305,6 @@ - name: Fetch Endpoints by ID (expect failed) ec2_vpc_endpoint_info: - query: endpoints vpc_endpoint_ids: '{{ endpoint_id }}' ignore_errors: true register: endpoint_info @@ -558,7 +522,6 @@ - name: Query by tag ec2_vpc_endpoint_info: - query: endpoints filters: tag:testPrefix: - '{{ resource_prefix }}' @@ -807,7 +770,6 @@ always: - name: Query any remain endpoints we created ec2_vpc_endpoint_info: - query: endpoints filters: vpc-id: - '{{ vpc_id }}' From 3b7e84d854fdec04ba27fa3edfddfd83388dea72 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Mon, 2 Jan 2023 16:36:01 +0100 Subject: [PATCH 2/3] Changelog --- changelogs/fragments/1308-ec2_vpc_endpoint_info-query.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/fragments/1308-ec2_vpc_endpoint_info-query.yml diff --git a/changelogs/fragments/1308-ec2_vpc_endpoint_info-query.yml b/changelogs/fragments/1308-ec2_vpc_endpoint_info-query.yml new file mode 100644 index 00000000000..180943b6e3a --- /dev/null +++ b/changelogs/fragments/1308-ec2_vpc_endpoint_info-query.yml @@ -0,0 +1,5 @@ +removed_features: +- ec2_vpc_endpoint_info - support for the ``query`` parameter was removed. + The ``amazon.aws.ec2_vpc_endpoint_info`` module now only queries for endpoints. + Services can be queried using the ``amazon.aws.ec2_vpc_endpoint_service_info`` module + (https://github.com/ansible-collections/amazon.aws/pull/1308). From 1ef9df55404dc14a2b112b0418c644584c440b56 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Mon, 2 Jan 2023 17:02:53 +0100 Subject: [PATCH 3/3] remove sanity ignore --- tests/sanity/ignore-2.11.txt | 1 - tests/sanity/ignore-2.12.txt | 1 - tests/sanity/ignore-2.13.txt | 1 - tests/sanity/ignore-2.14.txt | 1 - tests/sanity/ignore-2.15.txt | 1 - tests/sanity/ignore-2.9.txt | 1 - 6 files changed, 6 deletions(-) diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index 8002f467265..aa6957eceac 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -1,4 +1,3 @@ plugins/modules/ec2_vpc_dhcp_option.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1177 -plugins/modules/ec2_vpc_endpoint_info.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1179 plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this plugins/modules/route53_health_check.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1111 diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index 8002f467265..aa6957eceac 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -1,4 +1,3 @@ plugins/modules/ec2_vpc_dhcp_option.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1177 -plugins/modules/ec2_vpc_endpoint_info.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1179 plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this plugins/modules/route53_health_check.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1111 diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index 8002f467265..aa6957eceac 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -1,4 +1,3 @@ plugins/modules/ec2_vpc_dhcp_option.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1177 -plugins/modules/ec2_vpc_endpoint_info.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1179 plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this plugins/modules/route53_health_check.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1111 diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 8002f467265..aa6957eceac 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -1,4 +1,3 @@ plugins/modules/ec2_vpc_dhcp_option.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1177 -plugins/modules/ec2_vpc_endpoint_info.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1179 plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this plugins/modules/route53_health_check.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1111 diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 8002f467265..aa6957eceac 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -1,4 +1,3 @@ plugins/modules/ec2_vpc_dhcp_option.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1177 -plugins/modules/ec2_vpc_endpoint_info.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1179 plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this plugins/modules/route53_health_check.py pylint:collection-deprecated-version # https://github.com/ansible-collections/amazon.aws/issues/1111 diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt index 05114d1feaa..d8f026390ab 100644 --- a/tests/sanity/ignore-2.9.txt +++ b/tests/sanity/ignore-2.9.txt @@ -1,5 +1,4 @@ plugins/modules/ec2_vpc_dhcp_option.py pylint:ansible-deprecated-no-version # We use dates for deprecations, Ansible 2.9 only supports this for compatability -plugins/modules/ec2_vpc_endpoint_info.py pylint:ansible-deprecated-no-version # We use dates for deprecations, Ansible 2.9 only supports this for compatability plugins/modules/ec2_instance.py pylint:ansible-deprecated-no-version # We use dates for deprecations, Ansible 2.9 only supports this for compatability plugins/modules/iam_policy.py pylint:ansible-deprecated-no-version plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this