Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0.0] ec2_vpc_endpoint_info - Drop support for query #1308

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelogs/fragments/1308-ec2_vpc_endpoint_info-query.yml
Original file line number Diff line number Diff line change
@@ -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).
89 changes: 12 additions & 77 deletions plugins/modules/ec2_vpc_endpoint_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -69,27 +53,17 @@

- name: Get details on specific endpoint
amazon.aws.ec2_vpc_endpoint_info:
query: endpoints
region: ap-southeast-2
vpc_endpoint_ids:
- vpce-12345678
register: endpoint_details
'''

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:
Expand Down Expand Up @@ -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()
Expand All @@ -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'),
)
Expand All @@ -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)

Expand Down
38 changes: 0 additions & 38 deletions tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -240,7 +206,6 @@

- name: Fetch Endpoints (targetted by VPC)
ec2_vpc_endpoint_info:
query: endpoints
filters:
vpc-id:
- '{{ vpc_id }}'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -558,7 +522,6 @@

- name: Query by tag
ec2_vpc_endpoint_info:
query: endpoints
filters:
tag:testPrefix:
- '{{ resource_prefix }}'
Expand Down Expand Up @@ -807,7 +770,6 @@
always:
- name: Query any remain endpoints we created
ec2_vpc_endpoint_info:
query: endpoints
filters:
vpc-id:
- '{{ vpc_id }}'
Expand Down
1 change: 0 additions & 1 deletion tests/sanity/ignore-2.11.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion tests/sanity/ignore-2.12.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion tests/sanity/ignore-2.13.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion tests/sanity/ignore-2.14.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion tests/sanity/ignore-2.15.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion tests/sanity/ignore-2.9.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down