diff --git a/changelogs/fragments/migrate_ec2_vpc_endpoint.yml b/changelogs/fragments/migrate_ec2_vpc_endpoint.yml new file mode 100644 index 00000000000..9b10b55a905 --- /dev/null +++ b/changelogs/fragments/migrate_ec2_vpc_endpoint.yml @@ -0,0 +1,13 @@ +breaking_changes: +- ec2_vpc_endpoint_facts - 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.ec2_vpc_endpoint_info``. +- ec2_vpc_endpoint - 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.ec2_vpc_endpoint``. +- ec2_vpc_endpoint_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.ec2_vpc_endpoint_info``. +- ec2_vpc_endpoint_service_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.ec2_vpc_endpoint_service_info``. diff --git a/docs/community.aws.ec2_vpc_endpoint_info_module.rst b/docs/community.aws.ec2_vpc_endpoint_info_module.rst deleted file mode 100644 index 41e5eb15f28..00000000000 --- a/docs/community.aws.ec2_vpc_endpoint_info_module.rst +++ /dev/null @@ -1,387 +0,0 @@ -.. _community.aws.ec2_vpc_endpoint_info_module: - - -*********************************** -community.aws.ec2_vpc_endpoint_info -*********************************** - -**Retrieves AWS VPC endpoints details using AWS methods.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - - -Synopsis --------- -- Gets various details related to AWS VPC endpoints. -- This module was called ``ec2_vpc_endpoint_facts`` before Ansible 2.9. The usage did not change. - - - -Requirements ------------- -The below requirements are needed on the host that executes this module. - -- boto -- boto3 -- python >= 2.6 - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- aws_access_key - -
- string -
-
- -
AWS access key. If not set then the value of the AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY or EC2_ACCESS_KEY environment variable is used.
-
If profile is set this parameter is ignored.
-
Passing the aws_access_key and profile options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.
-

aliases: ec2_access_key, access_key
-
-
- aws_ca_bundle - -
- path -
-
- -
The location of a CA Bundle to use when validating SSL certificates.
-
Only used for boto3 based modules.
-
Note: The CA Bundle is read 'module' side and may need to be explicitly copied from the controller if not run locally.
-
-
- aws_config - -
- dictionary -
-
- -
A dictionary to modify the botocore configuration.
-
Parameters can be found at https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config.
-
Only the 'user_agent' key is used for boto modules. See http://boto.cloudhackers.com/en/latest/boto_config_tut.html#boto for more boto configuration.
-
-
- aws_secret_key - -
- string -
-
- -
AWS secret key. If not set then the value of the AWS_SECRET_ACCESS_KEY, AWS_SECRET_KEY, or EC2_SECRET_KEY environment variable is used.
-
If profile is set this parameter is ignored.
-
Passing the aws_secret_key and profile options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.
-

aliases: ec2_secret_key, secret_key
-
-
- debug_botocore_endpoint_logs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Use a botocore.endpoint logger to parse the unique (rather than total) "resource:action" API calls made during a task, outputing the set to the resource_actions key in the task results. Use the aws_resource_action callback to output to total list made during a playbook. The ANSIBLE_DEBUG_BOTOCORE_LOGS environment variable may also be used.
-
-
- ec2_url - -
- string -
-
- -
Url to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints). Ignored for modules where region is required. Must be specified for all other modules if region is not used. If not set then the value of the EC2_URL environment variable, if any, is used.
-

aliases: aws_endpoint_url, endpoint_url
-
-
- filters - -
- dictionary -
-
- -
A dict of filters to apply. Each dict item consists of a filter key and a filter value. See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcEndpoints.html for possible filters.
-
-
- profile - -
- string -
-
- -
Uses a boto profile. Only works with boto >= 2.24.0.
-
Using profile will override aws_access_key, aws_secret_key and security_token and support for passing them at the same time as profile has been deprecated.
-
aws_access_key, aws_secret_key and security_token will be made mutually exclusive with profile after 2022-06-01.
-

aliases: aws_profile
-
-
- query - -
- string -
-
-
    Choices: -
  • services
  • -
  • endpoints
  • -
-
-
Defaults to endpoints.
-
Specifies the query action to take.
-
query=endpoints returns information about AWS VPC endpoints.
-
Retrieving information about services using query=services has been deprecated in favour of the ec2_vpc_endpoint_service_info module.
-
The query option has been deprecated and will be removed after 2022-12-01.
-
-
- region - -
- string -
-
- -
The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION environment variable, if any, is used. See http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region
-

aliases: aws_region, ec2_region
-
-
- security_token - -
- string -
-
- -
AWS STS security token. If not set then the value of the AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN environment variable is used.
-
If profile is set this parameter is ignored.
-
Passing the security_token and profile options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.
-

aliases: aws_security_token, access_token
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0.
-
-
- vpc_endpoint_ids - -
- list - / elements=string -
-
- -
The IDs of specific endpoints to retrieve the details of.
-
-
- - -Notes ------ - -.. note:: - - If parameters are not set within the module, the following environment variables can be used in decreasing order of precedence ``AWS_URL`` or ``EC2_URL``, ``AWS_PROFILE`` or ``AWS_DEFAULT_PROFILE``, ``AWS_ACCESS_KEY_ID`` or ``AWS_ACCESS_KEY`` or ``EC2_ACCESS_KEY``, ``AWS_SECRET_ACCESS_KEY`` or ``AWS_SECRET_KEY`` or ``EC2_SECRET_KEY``, ``AWS_SECURITY_TOKEN`` or ``EC2_SECURITY_TOKEN``, ``AWS_REGION`` or ``EC2_REGION``, ``AWS_CA_BUNDLE`` - - Ansible uses the boto configuration file (typically ~/.boto) if no credentials are provided. See https://boto.readthedocs.io/en/latest/boto_config_tut.html - - ``AWS_REGION`` or ``EC2_REGION`` can be typically be used to specify the AWS region, when required, but this can also be configured in the boto config file - - - -Examples --------- - -.. code-block:: yaml - - # Simple example of listing all support AWS services for VPC endpoints - - name: List supported AWS endpoint services - community.aws.ec2_vpc_endpoint_info: - query: services - region: ap-southeast-2 - register: supported_endpoint_services - - - name: Get all endpoints in ap-southeast-2 region - community.aws.ec2_vpc_endpoint_info: - query: endpoints - region: ap-southeast-2 - register: existing_endpoints - - - name: Get all endpoints with specific filters - community.aws.ec2_vpc_endpoint_info: - query: endpoints - region: ap-southeast-2 - filters: - vpc-id: - - vpc-12345678 - - vpc-87654321 - vpc-endpoint-state: - - available - - pending - register: existing_endpoints - - - name: Get details on specific endpoint - community.aws.ec2_vpc_endpoint_info: - query: endpoints - region: ap-southeast-2 - vpc_endpoint_ids: - - vpce-12345678 - register: endpoint_details - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - - - - - - -
KeyReturnedDescription
-
- service_names - -
- list -
-
query is services -
AWS VPC endpoint service names
-
-
Sample:
-
{'service_names': ['com.amazonaws.ap-southeast-2.s3']}
-
-
- vpc_endpoints - -
- list -
-
query is endpoints -
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.
-
-
Sample:
-
{'vpc_endpoints': [{'creation_timestamp': '2017-02-16T11:06:48+00:00', 'policy_document': '"{\\"Version\\":\\"2012-10-17\\",\\"Id\\":\\"Policy1450910922815\\", \\"Statement\\":[{\\"Sid\\":\\"Stmt1450910920641\\",\\"Effect\\":\\"Allow\\", \\"Principal\\":\\"*\\",\\"Action\\":\\"s3:*\\",\\"Resource\\":[\\"arn:aws:s3:::*/*\\",\\"arn:aws:s3:::*\\"]}]}"\n', 'route_table_ids': ['rtb-abcd1234'], 'service_name': 'com.amazonaws.ap-southeast-2.s3', 'state': 'available', 'vpc_endpoint_id': 'vpce-abbad0d0', 'vpc_id': 'vpc-1111ffff'}]}
-
-

- - -Status ------- - - -Authors -~~~~~~~ - -- Karen Cheng (@Etherdaemon) diff --git a/docs/community.aws.ec2_vpc_endpoint_module.rst b/docs/community.aws.ec2_vpc_endpoint_module.rst deleted file mode 100644 index 13972b61a19..00000000000 --- a/docs/community.aws.ec2_vpc_endpoint_module.rst +++ /dev/null @@ -1,550 +0,0 @@ -.. _community.aws.ec2_vpc_endpoint_module: - - -****************************** -community.aws.ec2_vpc_endpoint -****************************** - -**Create and delete AWS VPC Endpoints.** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - - -Synopsis --------- -- Creates AWS VPC endpoints. -- Deletes AWS VPC endpoints. -- This module supports check mode. - - - -Requirements ------------- -The below requirements are needed on the host that executes this module. - -- boto -- boto3 -- python >= 2.6 - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- aws_access_key - -
- string -
-
- -
AWS access key. If not set then the value of the AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY or EC2_ACCESS_KEY environment variable is used.
-
If profile is set this parameter is ignored.
-
Passing the aws_access_key and profile options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.
-

aliases: ec2_access_key, access_key
-
-
- aws_ca_bundle - -
- path -
-
- -
The location of a CA Bundle to use when validating SSL certificates.
-
Only used for boto3 based modules.
-
Note: The CA Bundle is read 'module' side and may need to be explicitly copied from the controller if not run locally.
-
-
- aws_config - -
- dictionary -
-
- -
A dictionary to modify the botocore configuration.
- -
Only the 'user_agent' key is used for boto modules. See http://boto.cloudhackers.com/en/latest/boto_config_tut.html#boto for more boto configuration.
-
-
- aws_secret_key - -
- string -
-
- -
AWS secret key. If not set then the value of the AWS_SECRET_ACCESS_KEY, AWS_SECRET_KEY, or EC2_SECRET_KEY environment variable is used.
-
If profile is set this parameter is ignored.
-
Passing the aws_secret_key and profile options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.
-

aliases: ec2_secret_key, secret_key
-
-
- client_token - -
- string -
-
- -
Optional client token to ensure idempotency
-
-
- debug_botocore_endpoint_logs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Use a botocore.endpoint logger to parse the unique (rather than total) "resource:action" API calls made during a task, outputing the set to the resource_actions key in the task results. Use the aws_resource_action callback to output to total list made during a playbook. The ANSIBLE_DEBUG_BOTOCORE_LOGS environment variable may also be used.
-
-
- ec2_url - -
- string -
-
- -
Url to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints). Ignored for modules where region is required. Must be specified for all other modules if region is not used. If not set then the value of the EC2_URL environment variable, if any, is used.
-

aliases: aws_endpoint_url, endpoint_url
-
-
- policy - -
- json -
-
- -
A properly formatted json policy as string, see https://github.com/ansible/ansible/issues/7005#issuecomment-42894813. Cannot be used with policy_file.
-
Option when creating an endpoint. If not provided AWS will utilise a default policy which provides full access to the service.
-
-
- policy_file - -
- path -
-
- -
The path to the properly json formatted policy file, see https://github.com/ansible/ansible/issues/7005#issuecomment-42894813 on how to use it properly. Cannot be used with policy.
-
Option when creating an endpoint. If not provided AWS will utilise a default policy which provides full access to the service.
-
This option has been deprecated and will be removed after 2022-12-01 to maintain the existing functionality please use the policy option and a file lookup.
-

aliases: policy_path
-
-
- profile - -
- string -
-
- -
Uses a boto profile. Only works with boto >= 2.24.0.
-
Using profile will override aws_access_key, aws_secret_key and security_token and support for passing them at the same time as profile has been deprecated.
-
aws_access_key, aws_secret_key and security_token will be made mutually exclusive with profile after 2022-06-01.
-

aliases: aws_profile
-
-
- purge_tags - -
- boolean -
-
added in 1.5.0
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Delete any tags not specified in the task that are on the instance. This means you have to specify all the desired tags on each task affecting an instance.
-
-
- region - -
- string -
-
- -
The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION environment variable, if any, is used. See http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region
-

aliases: aws_region, ec2_region
-
-
- route_table_ids - -
- list - / elements=string -
-
- -
List of one or more route table ids to attach to the endpoint. A route is added to the route table with the destination of the endpoint if provided.
-
-
- security_token - -
- string -
-
- -
AWS STS security token. If not set then the value of the AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN environment variable is used.
-
If profile is set this parameter is ignored.
-
Passing the security_token and profile options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.
-

aliases: aws_security_token, access_token
-
-
- service - -
- string -
-
- -
An AWS supported vpc endpoint service. Use the community.aws.ec2_vpc_endpoint_info module to describe the supported endpoint services.
-
Required when creating an endpoint.
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
present to ensure resource is created.
-
absent to remove resource
-
-
- tags - -
- dictionary -
-
added in 1.5.0
-
- -
A dict of tags to apply to the internet gateway.
-
To remove all tags set tags={} and purge_tags=true.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0.
-
-
- vpc_endpoint_id - -
- string -
-
- -
One or more vpc endpoint ids to remove from the AWS account
-
-
- vpc_endpoint_type - -
- string -
-
added in 1.5.0
-
-
    Choices: -
  • Interface
  • -
  • Gateway ←
  • -
  • GatewayLoadBalancer
  • -
-
-
The type of endpoint.
-
-
- vpc_id - -
- string -
-
- -
Required when creating a VPC endpoint.
-
-
- wait - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
When specified, will wait for either available status for state present. Unfortunately this is ignored for delete actions due to a difference in behaviour from AWS.
-
-
- wait_timeout - -
- integer -
-
- Default:
320
-
-
Used in conjunction with wait. Number of seconds to wait for status. Unfortunately this is ignored for delete actions due to a difference in behaviour from AWS.
-
-
- - -Notes ------ - -.. note:: - - If parameters are not set within the module, the following environment variables can be used in decreasing order of precedence ``AWS_URL`` or ``EC2_URL``, ``AWS_PROFILE`` or ``AWS_DEFAULT_PROFILE``, ``AWS_ACCESS_KEY_ID`` or ``AWS_ACCESS_KEY`` or ``EC2_ACCESS_KEY``, ``AWS_SECRET_ACCESS_KEY`` or ``AWS_SECRET_KEY`` or ``EC2_SECRET_KEY``, ``AWS_SECURITY_TOKEN`` or ``EC2_SECURITY_TOKEN``, ``AWS_REGION`` or ``EC2_REGION``, ``AWS_CA_BUNDLE`` - - Ansible uses the boto configuration file (typically ~/.boto) if no credentials are provided. See https://boto.readthedocs.io/en/latest/boto_config_tut.html - - ``AWS_REGION`` or ``EC2_REGION`` can be typically be used to specify the AWS region, when required, but this can also be configured in the boto config file - - - -Examples --------- - -.. code-block:: yaml - - # Note: These examples do not set authentication details, see the AWS Guide for details. - - - name: Create new vpc endpoint with a json template for policy - community.aws.ec2_vpc_endpoint: - state: present - region: ap-southeast-2 - vpc_id: vpc-12345678 - service: com.amazonaws.ap-southeast-2.s3 - policy: " {{ lookup( 'template', 'endpoint_policy.json.j2') }} " - route_table_ids: - - rtb-12345678 - - rtb-87654321 - register: new_vpc_endpoint - - - name: Create new vpc endpoint with the default policy - community.aws.ec2_vpc_endpoint: - state: present - region: ap-southeast-2 - vpc_id: vpc-12345678 - service: com.amazonaws.ap-southeast-2.s3 - route_table_ids: - - rtb-12345678 - - rtb-87654321 - register: new_vpc_endpoint - - - name: Create new vpc endpoint with json file - community.aws.ec2_vpc_endpoint: - state: present - region: ap-southeast-2 - vpc_id: vpc-12345678 - service: com.amazonaws.ap-southeast-2.s3 - policy_file: "{{ role_path }}/files/endpoint_policy.json" - route_table_ids: - - rtb-12345678 - - rtb-87654321 - register: new_vpc_endpoint - - - name: Delete newly created vpc endpoint - community.aws.ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ new_vpc_endpoint.result['VpcEndpointId'] }}" - region: ap-southeast-2 - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - -
KeyReturnedDescription
-
- endpoints - -
- list -
-
success -
The resulting endpoints from the module call
-
-
Sample:
-
[{'creation_timestamp': '2017-02-20T05:04:15+00:00', 'policy_document': {'Id': 'Policy1450910922815', 'Statement': [{'Action': 's3:*', 'Effect': 'Allow', 'Principal': '*', 'Resource': ['arn:aws:s3:::*/*', 'arn:aws:s3:::*'], 'Sid': 'Stmt1450910920641'}], 'Version': '2012-10-17'}, 'route_table_ids': ['rtb-abcd1234'], 'service_name': 'com.amazonaws.ap-southeast-2.s3', 'vpc_endpoint_id': 'vpce-a1b2c3d4', 'vpc_id': 'vpc-abbad0d0'}]
-
-

- - -Status ------- - - -Authors -~~~~~~~ - -- Karen Cheng (@Etherdaemon) diff --git a/docs/community.aws.ec2_vpc_endpoint_service_info_module.rst b/docs/community.aws.ec2_vpc_endpoint_service_info_module.rst deleted file mode 100644 index 3ae559e6026..00000000000 --- a/docs/community.aws.ec2_vpc_endpoint_service_info_module.rst +++ /dev/null @@ -1,544 +0,0 @@ -.. _community.aws.ec2_vpc_endpoint_service_info_module: - - -******************************************* -community.aws.ec2_vpc_endpoint_service_info -******************************************* - -**retrieves AWS VPC endpoint service details** - - -Version added: 1.5.0 - -.. contents:: - :local: - :depth: 1 - - -Synopsis --------- -- Gets details related to AWS VPC Endpoint Services. - - - -Requirements ------------- -The below requirements are needed on the host that executes this module. - -- boto -- boto3 -- python >= 2.6 - - -Parameters ----------- - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterChoices/DefaultsComments
-
- aws_access_key - -
- string -
-
- -
AWS access key. If not set then the value of the AWS_ACCESS_KEY_ID, AWS_ACCESS_KEY or EC2_ACCESS_KEY environment variable is used.
-
If profile is set this parameter is ignored.
-
Passing the aws_access_key and profile options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.
-

aliases: ec2_access_key, access_key
-
-
- aws_ca_bundle - -
- path -
-
- -
The location of a CA Bundle to use when validating SSL certificates.
-
Only used for boto3 based modules.
-
Note: The CA Bundle is read 'module' side and may need to be explicitly copied from the controller if not run locally.
-
-
- aws_config - -
- dictionary -
-
- -
A dictionary to modify the botocore configuration.
- -
Only the 'user_agent' key is used for boto modules. See http://boto.cloudhackers.com/en/latest/boto_config_tut.html#boto for more boto configuration.
-
-
- aws_secret_key - -
- string -
-
- -
AWS secret key. If not set then the value of the AWS_SECRET_ACCESS_KEY, AWS_SECRET_KEY, or EC2_SECRET_KEY environment variable is used.
-
If profile is set this parameter is ignored.
-
Passing the aws_secret_key and profile options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.
-

aliases: ec2_secret_key, secret_key
-
-
- debug_botocore_endpoint_logs - -
- boolean -
-
-
    Choices: -
  • no ←
  • -
  • yes
  • -
-
-
Use a botocore.endpoint logger to parse the unique (rather than total) "resource:action" API calls made during a task, outputing the set to the resource_actions key in the task results. Use the aws_resource_action callback to output to total list made during a playbook. The ANSIBLE_DEBUG_BOTOCORE_LOGS environment variable may also be used.
-
-
- ec2_url - -
- string -
-
- -
Url to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints). Ignored for modules where region is required. Must be specified for all other modules if region is not used. If not set then the value of the EC2_URL environment variable, if any, is used.
-

aliases: aws_endpoint_url, endpoint_url
-
-
- filters - -
- dictionary -
-
- -
A dict of filters to apply.
-
Each dict item consists of a filter key and a filter value. See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeVpcEndpointServices.html for possible filters.
-
-
- profile - -
- string -
-
- -
Uses a boto profile. Only works with boto >= 2.24.0.
-
Using profile will override aws_access_key, aws_secret_key and security_token and support for passing them at the same time as profile has been deprecated.
-
aws_access_key, aws_secret_key and security_token will be made mutually exclusive with profile after 2022-06-01.
-

aliases: aws_profile
-
-
- region - -
- string -
-
- -
The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION environment variable, if any, is used. See http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region
-

aliases: aws_region, ec2_region
-
-
- security_token - -
- string -
-
- -
AWS STS security token. If not set then the value of the AWS_SECURITY_TOKEN or EC2_SECURITY_TOKEN environment variable is used.
-
If profile is set this parameter is ignored.
-
Passing the security_token and profile options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01.
-

aliases: aws_security_token, access_token
-
-
- service_names - -
- list - / elements=string -
-
- -
A list of service names which can be used to narrow the search results.
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0.
-
-
- - -Notes ------ - -.. note:: - - If parameters are not set within the module, the following environment variables can be used in decreasing order of precedence ``AWS_URL`` or ``EC2_URL``, ``AWS_PROFILE`` or ``AWS_DEFAULT_PROFILE``, ``AWS_ACCESS_KEY_ID`` or ``AWS_ACCESS_KEY`` or ``EC2_ACCESS_KEY``, ``AWS_SECRET_ACCESS_KEY`` or ``AWS_SECRET_KEY`` or ``EC2_SECRET_KEY``, ``AWS_SECURITY_TOKEN`` or ``EC2_SECURITY_TOKEN``, ``AWS_REGION`` or ``EC2_REGION``, ``AWS_CA_BUNDLE`` - - Ansible uses the boto configuration file (typically ~/.boto) if no credentials are provided. See https://boto.readthedocs.io/en/latest/boto_config_tut.html - - ``AWS_REGION`` or ``EC2_REGION`` can be typically be used to specify the AWS region, when required, but this can also be configured in the boto config file - - - -Examples --------- - -.. code-block:: yaml - - # Simple example of listing all supported AWS services for VPC endpoints - - name: List supported AWS endpoint services - community.aws.ec2_vpc_endpoint_service_info: - region: ap-southeast-2 - register: supported_endpoint_services - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KeyReturnedDescription
-
- service_details - -
- complex -
-
success -
Detailed information about the AWS VPC endpoint services.
-
-
  -
- acceptance_required - -
- boolean -
-
success -
Whether VPC endpoint connection requests to the service must be accepted by the service owner.
-
-
  -
- availability_zones - -
- list -
-
success -
The Availability Zones in which the service is available.
-
-
  -
- base_endpoint_dns_names - -
- list -
-
success -
The DNS names for the service.
-
-
  -
- manages_vpc_endpoints - -
- boolean -
-
success -
Whether the service manages its VPC endpoints.
-
-
  -
- owner - -
- string -
-
success -
The AWS account ID of the service owner.
-
-
  -
- private_dns_name - -
- string -
-
success -
The private DNS name for the service.
-
-
  -
- private_dns_name_verification_state - -
- string -
-
success -
The verification state of the VPC endpoint service.
-
Consumers of an endpoint service cannot use the private name when the state is not verified.
-
-
  -
- private_dns_names - -
- list -
-
success -
The private DNS names assigned to the VPC endpoint service.
-
-
  -
- service_id - -
- string -
-
success -
The ID of the endpoint service.
-
-
  -
- service_name - -
- string -
-
success -
The ARN of the endpoint service.
-
-
  -
- service_type - -
- list -
-
success -
The type of the service
-
-
  -
- tags - -
- dictionary -
-
success -
A dict of tags associated with the service
-
-
  -
- vpc_endpoint_policy_supported - -
- boolean -
-
success -
Whether the service supports endpoint policies.
-
-
-
- service_names - -
- list -
-
success -
List of supported AWS VPC endpoint service names.
-
-
Sample:
-
{'service_names': ['com.amazonaws.ap-southeast-2.s3']}
-
-

- - -Status ------- - - -Authors -~~~~~~~ - -- Mark Chappell (@tremble) diff --git a/meta/runtime.yml b/meta/runtime.yml index 6a8a9feff8a..0fbca024bee 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -21,7 +21,6 @@ action_groups: - ec2_elb_facts - ec2_lc_facts - ec2_placement_group_facts - - ec2_vpc_endpoint_facts - ec2_vpc_igw_facts - ec2_vpc_nacl_facts - ec2_vpc_peering_facts @@ -125,9 +124,6 @@ action_groups: - ec2_transit_gateway - ec2_transit_gateway_info - ec2_vpc_egress_igw - - ec2_vpc_endpoint - - ec2_vpc_endpoint_info - - ec2_vpc_endpoint_service_info - ec2_vpc_igw - ec2_vpc_igw_info - ec2_vpc_nacl @@ -338,12 +334,13 @@ plugin_routing: ec2_placement_group_info. Please update your tasks. ec2_vpc_endpoint_facts: - deprecation: - removal_date: 2021-12-01 - warning_text: >- - ec2_vpc_endpoint_facts was renamed in Ansible 2.9 to - ec2_vpc_endpoint_info. - Please update your tasks. + redirect: amazon.aws.ec2_vpc_endpoint_facts + ec2_vpc_endpoint: + redirect: amazon.aws.ec2_vpc_endpoint + ec2_vpc_endpoint_info: + redirect: amazon.aws.ec2_vpc_endpoint_info + ec2_vpc_endpoint_service_info: + redirect: amazon.aws.ec2_vpc_endpoint_service_info ec2_vpc_igw_facts: deprecation: removal_date: 2021-12-01 @@ -370,6 +367,12 @@ plugin_routing: ec2_vpc_route_table_facts was renamed in Ansible 2.9 to ec2_vpc_route_table_info. Please update your tasks. + ec2_vpc_nat_gateway_facts: + redirect: amazon.aws.ec2_vpc_nat_gateway_facts + ec2_vpc_nat_gateway: + redirect: amazon.aws.ec2_vpc_nat_gateway + ec2_vpc_nat_gateway_info: + redirect: amazon.aws.ec2_vpc_nat_gateway_info ec2_vpc_vgw_facts: deprecation: removal_date: 2021-12-01 @@ -508,9 +511,3 @@ plugin_routing: warning_text: >- route53_facts was renamed in Ansible 2.9 to route53_info. Please update your tasks. - ec2_vpc_nat_gateway_facts: - redirect: amazon.aws.ec2_vpc_nat_gateway_facts - ec2_vpc_nat_gateway: - redirect: amazon.aws.ec2_vpc_nat_gateway - ec2_vpc_nat_gateway_info: - redirect: amazon.aws.ec2_vpc_nat_gateway_info diff --git a/plugins/modules/ec2_vpc_endpoint.py b/plugins/modules/ec2_vpc_endpoint.py deleted file mode 100644 index 75ba2479afe..00000000000 --- a/plugins/modules/ec2_vpc_endpoint.py +++ /dev/null @@ -1,480 +0,0 @@ -#!/usr/bin/python -# Copyright: Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - - -DOCUMENTATION = r''' -module: ec2_vpc_endpoint -short_description: Create and delete AWS VPC Endpoints. -version_added: 1.0.0 -description: - - Creates AWS VPC endpoints. - - Deletes AWS VPC endpoints. - - This module supports check mode. -options: - vpc_id: - description: - - Required when creating a VPC endpoint. - required: false - type: str - vpc_endpoint_type: - description: - - The type of endpoint. - required: false - default: Gateway - choices: [ "Interface", "Gateway", "GatewayLoadBalancer" ] - type: str - version_added: 1.5.0 - service: - description: - - An AWS supported vpc endpoint service. Use the M(community.aws.ec2_vpc_endpoint_info) - module to describe the supported endpoint services. - - Required when creating an endpoint. - required: false - type: str - policy: - description: - - A properly formatted json policy as string, see - U(https://github.com/ansible/ansible/issues/7005#issuecomment-42894813). - Cannot be used with I(policy_file). - - Option when creating an endpoint. If not provided AWS will - utilise a default policy which provides full access to the service. - required: false - type: json - policy_file: - description: - - The path to the properly json formatted policy file, see - U(https://github.com/ansible/ansible/issues/7005#issuecomment-42894813) - on how to use it properly. Cannot be used with I(policy). - - Option when creating an endpoint. If not provided AWS will - utilise a default policy which provides full access to the service. - - This option has been deprecated and will be removed after 2022-12-01 - to maintain the existing functionality please use the I(policy) option - and a file lookup. - required: false - aliases: [ "policy_path" ] - type: path - state: - description: - - present to ensure resource is created. - - absent to remove resource - required: false - default: present - choices: [ "present", "absent" ] - type: str - tags: - description: - - A dict of tags to apply to the internet gateway. - - To remove all tags set I(tags={}) and I(purge_tags=true). - type: dict - version_added: 1.5.0 - purge_tags: - description: - - Delete any tags not specified in the task that are on the instance. - This means you have to specify all the desired tags on each task affecting an instance. - default: false - type: bool - version_added: 1.5.0 - wait: - description: - - When specified, will wait for either available status for state present. - Unfortunately this is ignored for delete actions due to a difference in - behaviour from AWS. - required: false - default: no - type: bool - wait_timeout: - description: - - Used in conjunction with wait. Number of seconds to wait for status. - Unfortunately this is ignored for delete actions due to a difference in - behaviour from AWS. - required: false - default: 320 - type: int - route_table_ids: - description: - - List of one or more route table ids to attach to the endpoint. A route - is added to the route table with the destination of the endpoint if - provided. - required: false - type: list - elements: str - vpc_endpoint_id: - description: - - One or more vpc endpoint ids to remove from the AWS account - required: false - type: str - client_token: - description: - - Optional client token to ensure idempotency - required: false - type: str -author: Karen Cheng (@Etherdaemon) -extends_documentation_fragment: -- amazon.aws.aws -- amazon.aws.ec2 - -''' - -EXAMPLES = r''' -# Note: These examples do not set authentication details, see the AWS Guide for details. - -- name: Create new vpc endpoint with a json template for policy - community.aws.ec2_vpc_endpoint: - state: present - region: ap-southeast-2 - vpc_id: vpc-12345678 - service: com.amazonaws.ap-southeast-2.s3 - policy: " {{ lookup( 'template', 'endpoint_policy.json.j2') }} " - route_table_ids: - - rtb-12345678 - - rtb-87654321 - register: new_vpc_endpoint - -- name: Create new vpc endpoint with the default policy - community.aws.ec2_vpc_endpoint: - state: present - region: ap-southeast-2 - vpc_id: vpc-12345678 - service: com.amazonaws.ap-southeast-2.s3 - route_table_ids: - - rtb-12345678 - - rtb-87654321 - register: new_vpc_endpoint - -- name: Create new vpc endpoint with json file - community.aws.ec2_vpc_endpoint: - state: present - region: ap-southeast-2 - vpc_id: vpc-12345678 - service: com.amazonaws.ap-southeast-2.s3 - policy_file: "{{ role_path }}/files/endpoint_policy.json" - route_table_ids: - - rtb-12345678 - - rtb-87654321 - register: new_vpc_endpoint - -- name: Delete newly created vpc endpoint - community.aws.ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ new_vpc_endpoint.result['VpcEndpointId'] }}" - region: ap-southeast-2 -''' - -RETURN = r''' -endpoints: - description: The resulting endpoints from the module call - returned: success - type: list - sample: [ - { - "creation_timestamp": "2017-02-20T05:04:15+00:00", - "policy_document": { - "Id": "Policy1450910922815", - "Statement": [ - { - "Action": "s3:*", - "Effect": "Allow", - "Principal": "*", - "Resource": [ - "arn:aws:s3:::*/*", - "arn:aws:s3:::*" - ], - "Sid": "Stmt1450910920641" - } - ], - "Version": "2012-10-17" - }, - "route_table_ids": [ - "rtb-abcd1234" - ], - "service_name": "com.amazonaws.ap-southeast-2.s3", - "vpc_endpoint_id": "vpce-a1b2c3d4", - "vpc_id": "vpc-abbad0d0" - } - ] -''' - -import datetime -import json -import traceback - -try: - import botocore -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_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.core import normalize_boto3_result -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ansible_dict_to_boto3_filter_list -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ansible_dict_to_boto3_tag_list -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_tag_list_to_ansible_dict -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import compare_aws_tags - -from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter - - -def get_endpoints(client, module, endpoint_id=None): - params = dict() - if endpoint_id: - params['VpcEndpointIds'] = [endpoint_id] - else: - filters = list() - if module.params.get('service'): - filters.append({'Name': 'service-name', 'Values': [module.params.get('service')]}) - if module.params.get('vpc_id'): - filters.append({'Name': 'vpc-id', 'Values': [module.params.get('vpc_id')]}) - params['Filters'] = filters - try: - result = client.describe_vpc_endpoints(aws_retry=True, **params) - except (botocore.exceptions.BotoCoreError, botocore.exceptions.ClientError) as e: - module.fail_json_aws(e, msg="Failed to get endpoints") - - # normalize iso datetime fields in result - normalized_result = normalize_boto3_result(result) - return normalized_result - - -def match_endpoints(route_table_ids, service_name, vpc_id, endpoint): - found = False - sorted_route_table_ids = [] - - if route_table_ids: - sorted_route_table_ids = sorted(route_table_ids) - - if endpoint['VpcId'] == vpc_id and endpoint['ServiceName'] == service_name: - sorted_endpoint_rt_ids = sorted(endpoint['RouteTableIds']) - if sorted_endpoint_rt_ids == sorted_route_table_ids: - - found = True - return found - - -def ensure_tags(client, module, vpc_endpoint_id): - changed = False - tags = module.params['tags'] - purge_tags = module.params['purge_tags'] - - filters = ansible_dict_to_boto3_filter_list({'resource-id': vpc_endpoint_id}) - try: - current_tags = client.describe_tags(aws_retry=True, Filters=filters) - except (botocore.exceptions.BotoCoreError, botocore.exceptions.ClientError) as e: - module.fail_json_aws(e, msg="Failed to describe tags for VPC Endpoint: {0}".format(vpc_endpoint_id)) - - tags_to_set, tags_to_unset = compare_aws_tags(boto3_tag_list_to_ansible_dict(current_tags.get('Tags')), tags, purge_tags=purge_tags) - if purge_tags and not tags: - tags_to_unset = current_tags - - if tags_to_unset: - changed = True - if not module.check_mode: - try: - client.delete_tags(aws_retry=True, Resources=[vpc_endpoint_id], Tags=[dict(Key=tagkey) for tagkey in tags_to_unset]) - except (botocore.exceptions.BotoCoreError, botocore.exceptions.ClientError) as e: - module.fail_json_aws(e, msg="Unable to delete tags {0}".format(tags_to_unset)) - - if tags_to_set: - changed = True - if not module.check_mode: - try: - client.create_tags(aws_retry=True, Resources=[vpc_endpoint_id], Tags=ansible_dict_to_boto3_tag_list(tags_to_set)) - except (botocore.exceptions.BotoCoreError, botocore.exceptions.ClientError) as e: - module.fail_json_aws(e, msg="Unable to add tags {0}".format(tags_to_set)) - return changed - - -def setup_creation(client, module): - endpoint_id = module.params.get('vpc_endpoint_id') - route_table_ids = module.params.get('route_table_ids') - service_name = module.params.get('service') - vpc_id = module.params.get('vpc_id') - changed = False - - if not endpoint_id: - # Try to use the module parameters to match any existing endpoints - all_endpoints = get_endpoints(client, module, endpoint_id) - if len(all_endpoints['VpcEndpoints']) > 0: - for endpoint in all_endpoints['VpcEndpoints']: - if match_endpoints(route_table_ids, service_name, vpc_id, endpoint): - endpoint_id = endpoint['VpcEndpointId'] - break - - if endpoint_id: - # If we have an endpoint now, just ensure tags and exit - if module.params.get('tags'): - changed = ensure_tags(client, module, endpoint_id) - normalized_result = get_endpoints(client, module, endpoint_id=endpoint_id)['VpcEndpoints'][0] - return changed, camel_dict_to_snake_dict(normalized_result, ignore_list=['Tags']) - - changed, result = create_vpc_endpoint(client, module) - - return changed, camel_dict_to_snake_dict(result, ignore_list=['Tags']) - - -def create_vpc_endpoint(client, module): - params = dict() - changed = False - token_provided = False - params['VpcId'] = module.params.get('vpc_id') - params['VpcEndpointType'] = module.params.get('vpc_endpoint_type') - params['ServiceName'] = module.params.get('service') - - if module.check_mode: - changed = True - result = 'Would have created VPC Endpoint if not in check mode' - module.exit_json(changed=changed, result=result) - - if module.params.get('route_table_ids'): - params['RouteTableIds'] = module.params.get('route_table_ids') - - if module.params.get('client_token'): - token_provided = True - request_time = datetime.datetime.utcnow() - params['ClientToken'] = module.params.get('client_token') - - policy = None - if module.params.get('policy'): - try: - policy = json.loads(module.params.get('policy')) - except ValueError as e: - module.fail_json(msg=str(e), exception=traceback.format_exc(), - **camel_dict_to_snake_dict(e.response)) - - elif module.params.get('policy_file'): - try: - with open(module.params.get('policy_file'), 'r') as json_data: - policy = json.load(json_data) - except Exception as e: - module.fail_json(msg=str(e), exception=traceback.format_exc(), - **camel_dict_to_snake_dict(e.response)) - - if policy: - params['PolicyDocument'] = json.dumps(policy) - - try: - changed = True - result = client.create_vpc_endpoint(aws_retry=True, **params)['VpcEndpoint'] - if token_provided and (request_time > result['creation_timestamp'].replace(tzinfo=None)): - changed = False - elif module.params.get('wait') and not module.check_mode: - try: - waiter = get_waiter(client, 'vpc_endpoint_exists') - waiter.wait(VpcEndpointIds=[result['VpcEndpointId']], WaiterConfig=dict(Delay=15, MaxAttempts=module.params.get('wait_timeout') // 15)) - except botocore.exceptions.WaiterError as e: - module.fail_json_aws(msg='Error waiting for vpc endpoint to become available - please check the AWS console') - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except - module.fail_json_aws(e, msg='Failure while waiting for status') - - except is_boto3_error_code('IdempotentParameterMismatch'): # pylint: disable=duplicate-except - module.fail_json(msg="IdempotentParameterMismatch - updates of endpoints are not allowed by the API") - except is_boto3_error_code('RouteAlreadyExists'): # pylint: disable=duplicate-except - module.fail_json(msg="RouteAlreadyExists for one of the route tables - update is not allowed by the API") - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except - module.fail_json_aws(e, msg="Failed to create VPC.") - - if module.params.get('tags'): - ensure_tags(client, module, result['VpcEndpointId']) - - # describe and normalize iso datetime fields in result after adding tags - normalized_result = get_endpoints(client, module, endpoint_id=result['VpcEndpointId'])['VpcEndpoints'][0] - return changed, normalized_result - - -def setup_removal(client, module): - params = dict() - changed = False - - if module.check_mode: - try: - exists = client.describe_vpc_endpoints(aws_retry=True, VpcEndpointIds=[module.params.get('vpc_endpoint_id')]) - if exists: - result = {'msg': 'Would have deleted VPC Endpoint if not in check mode'} - changed = True - except is_boto3_error_code('InvalidVpcEndpointId.NotFound'): - result = {'msg': 'Endpoint does not exist, nothing to delete.'} - changed = False - except (botocore.exceptions.BotoCoreError, botocore.exceptions.ClientError) as e: # pylint: disable=duplicate-except - module.fail_json_aws(e, msg="Failed to get endpoints") - - return changed, result - - if isinstance(module.params.get('vpc_endpoint_id'), string_types): - params['VpcEndpointIds'] = [module.params.get('vpc_endpoint_id')] - else: - params['VpcEndpointIds'] = module.params.get('vpc_endpoint_id') - try: - result = client.delete_vpc_endpoints(aws_retry=True, **params)['Unsuccessful'] - if len(result) < len(params['VpcEndpointIds']): - changed = True - # For some reason delete_vpc_endpoints doesn't throw exceptions it - # returns a list of failed 'results' instead. Throw these so we can - # catch them the way we expect - for r in result: - try: - raise botocore.exceptions.ClientError(r, 'delete_vpc_endpoints') - except is_boto3_error_code('InvalidVpcEndpoint.NotFound'): - continue - - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except - module.fail_json_aws(e, "Failed to delete VPC endpoint") - return changed, result - - -def main(): - argument_spec = dict( - vpc_id=dict(), - vpc_endpoint_type=dict(default='Gateway', choices=['Interface', 'Gateway', 'GatewayLoadBalancer']), - service=dict(), - policy=dict(type='json'), - policy_file=dict(type='path', aliases=['policy_path']), - state=dict(default='present', choices=['present', 'absent']), - wait=dict(type='bool', default=False), - wait_timeout=dict(type='int', default=320, required=False), - route_table_ids=dict(type='list', elements='str'), - vpc_endpoint_id=dict(), - client_token=dict(no_log=False), - tags=dict(type='dict'), - purge_tags=dict(type='bool', default=False), - ) - module = AnsibleAWSModule( - argument_spec=argument_spec, - supports_check_mode=True, - mutually_exclusive=[['policy', 'policy_file']], - required_if=[ - ['state', 'present', ['vpc_id', 'service']], - ['state', 'absent', ['vpc_endpoint_id']], - ], - ) - - # Validate Requirements - state = module.params.get('state') - - if module.params.get('policy_file'): - module.deprecate('The policy_file option has been deprecated and' - ' will be removed after 2022-12-01', - date='2022-12-01', collection_name='community.aws') - - try: - ec2 = module.client('ec2', retry_decorator=AWSRetry.jittered_backoff()) - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - module.fail_json_aws(e, msg='Failed to connect to AWS') - - # Ensure resource is present - if state == 'present': - (changed, results) = setup_creation(ec2, module) - else: - (changed, results) = setup_removal(ec2, module) - - module.exit_json(changed=changed, result=results) - - -if __name__ == '__main__': - main() diff --git a/plugins/modules/ec2_vpc_endpoint_facts.py b/plugins/modules/ec2_vpc_endpoint_facts.py deleted file mode 120000 index d2a144a7b86..00000000000 --- a/plugins/modules/ec2_vpc_endpoint_facts.py +++ /dev/null @@ -1 +0,0 @@ -ec2_vpc_endpoint_info.py \ No newline at end of file diff --git a/plugins/modules/ec2_vpc_endpoint_info.py b/plugins/modules/ec2_vpc_endpoint_info.py deleted file mode 100644 index f84434cb9af..00000000000 --- a/plugins/modules/ec2_vpc_endpoint_info.py +++ /dev/null @@ -1,210 +0,0 @@ -#!/usr/bin/python -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - - -DOCUMENTATION = r''' -module: ec2_vpc_endpoint_info -short_description: Retrieves AWS VPC endpoints details using AWS methods. -version_added: 1.0.0 -description: - - Gets various details related to AWS VPC endpoints. - - This module was called C(ec2_vpc_endpoint_facts) before Ansible 2.9. The usage did not change. -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(ec2_vpc_endpoint_service_info) module. - - The I(query) option has been deprecated and will be removed after 2022-12-01. - required: False - choices: - - services - - endpoints - type: str - vpc_endpoint_ids: - description: - - The IDs of specific endpoints to retrieve the details of. - type: list - elements: str - 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_DescribeVpcEndpoints.html) - for possible filters. - type: dict -author: Karen Cheng (@Etherdaemon) -extends_documentation_fragment: -- amazon.aws.aws -- amazon.aws.ec2 - -''' - -EXAMPLES = r''' -# Simple example of listing all support AWS services for VPC endpoints -- name: List supported AWS endpoint services - community.aws.ec2_vpc_endpoint_info: - query: services - region: ap-southeast-2 - register: supported_endpoint_services - -- name: Get all endpoints in ap-southeast-2 region - community.aws.ec2_vpc_endpoint_info: - query: endpoints - region: ap-southeast-2 - register: existing_endpoints - -- name: Get all endpoints with specific filters - community.aws.ec2_vpc_endpoint_info: - query: endpoints - region: ap-southeast-2 - filters: - vpc-id: - - vpc-12345678 - - vpc-87654321 - vpc-endpoint-state: - - available - - pending - register: existing_endpoints - -- name: Get details on specific endpoint - community.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 - 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) - type: list - sample: - vpc_endpoints: - - creation_timestamp: "2017-02-16T11:06:48+00:00" - policy_document: > - "{\"Version\":\"2012-10-17\",\"Id\":\"Policy1450910922815\", - \"Statement\":[{\"Sid\":\"Stmt1450910920641\",\"Effect\":\"Allow\", - \"Principal\":\"*\",\"Action\":\"s3:*\",\"Resource\":[\"arn:aws:s3:::*/*\",\"arn:aws:s3:::*\"]}]}" - route_table_ids: - - rtb-abcd1234 - service_name: "com.amazonaws.ap-southeast-2.s3" - state: "available" - vpc_endpoint_id: "vpce-abbad0d0" - vpc_id: "vpc-1111ffff" -''' - -try: - 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.core import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code -from ansible_collections.amazon.aws.plugins.module_utils.core import normalize_boto3_result -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ansible_dict_to_boto3_filter_list - - -@AWSRetry.jittered_backoff() -def _describe_endpoints(client, **params): - paginator = client.get_paginator('describe_vpc_endpoints') - 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() - params['Filters'] = ansible_dict_to_boto3_filter_list(module.params.get('filters')) - if module.params.get('vpc_endpoint_ids'): - params['VpcEndpointIds'] = module.params.get('vpc_endpoint_ids') - try: - results = _describe_endpoints(client, **params)['VpcEndpoints'] - results = normalize_boto3_result(results) - except is_boto3_error_code('InvalidVpcEndpointId.NotFound'): - module.exit_json(msg='VpcEndpoint {0} does not exist'.format(module.params.get('vpc_endpoint_ids')), vpc_endpoints=[]) - except (botocore.exceptions.BotoCoreError, botocore.exceptions.ClientError) as e: # pylint: disable=duplicate-except - module.fail_json_aws(e, msg="Failed to get endpoints") - - return dict(vpc_endpoints=[camel_dict_to_snake_dict(result) for result in results]) - - -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'), - ) - - module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) - if module._name == 'ec2_vpc_endpoint_facts': - module.deprecate("The 'ec2_vpc_endpoint_facts' module has been renamed to 'ec2_vpc_endpoint_info'", date='2021-12-01', collection_name='community.aws') - - # Validate Requirements - try: - connection = module.client('ec2') - 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 after 2022-12-01. Searching for' - ' `endpoints` is now the default and after' - ' 2022-12-01 this module will only support fetching' - ' endpoints.', - date='2022-12-01', collection_name='community.aws') - elif query == 'services': - module.deprecate('Support for fetching service information with this ' - 'module has been deprecated and will be removed after' - ' 2022-12-01. ' - 'Please use the ec2_vpc_endpoint_service_info module ' - 'instead.', date='2022-12-01', - collection_name='community.aws') - else: - query = 'endpoints' - - invocations = { - 'services': get_supported_services, - 'endpoints': get_endpoints, - } - results = invocations[query](connection, module) - - module.exit_json(**results) - - -if __name__ == '__main__': - main() diff --git a/plugins/modules/ec2_vpc_endpoint_service_info.py b/plugins/modules/ec2_vpc_endpoint_service_info.py deleted file mode 100644 index 8dee0652b84..00000000000 --- a/plugins/modules/ec2_vpc_endpoint_service_info.py +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/python -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - - -DOCUMENTATION = r''' -module: ec2_vpc_endpoint_service_info -short_description: retrieves AWS VPC endpoint service details -version_added: 1.5.0 -description: - - Gets details related to AWS VPC Endpoint Services. -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_DescribeVpcEndpointServices.html) - for possible filters. - type: dict - service_names: - description: - - A list of service names which can be used to narrow the search results. - type: list - elements: str -author: - - Mark Chappell (@tremble) -extends_documentation_fragment: - - amazon.aws.aws - - amazon.aws.ec2 - -''' - -EXAMPLES = r''' -# Simple example of listing all supported AWS services for VPC endpoints -- name: List supported AWS endpoint services - community.aws.ec2_vpc_endpoint_service_info: - region: ap-southeast-2 - register: supported_endpoint_services -''' - -RETURN = r''' -service_names: - description: List of supported AWS VPC endpoint service names. - returned: success - type: list - sample: - service_names: - - com.amazonaws.ap-southeast-2.s3 -service_details: - description: Detailed information about the AWS VPC endpoint services. - returned: success - type: complex - contains: - service_name: - returned: success - description: The ARN of the endpoint service. - type: str - service_id: - returned: success - description: The ID of the endpoint service. - type: str - service_type: - returned: success - description: The type of the service - type: list - availability_zones: - returned: success - description: The Availability Zones in which the service is available. - type: list - owner: - returned: success - description: The AWS account ID of the service owner. - type: str - base_endpoint_dns_names: - returned: success - description: The DNS names for the service. - type: list - private_dns_name: - returned: success - description: The private DNS name for the service. - type: str - private_dns_names: - returned: success - description: The private DNS names assigned to the VPC endpoint service. - type: list - vpc_endpoint_policy_supported: - returned: success - description: Whether the service supports endpoint policies. - type: bool - acceptance_required: - returned: success - description: - Whether VPC endpoint connection requests to the service must be - accepted by the service owner. - type: bool - manages_vpc_endpoints: - returned: success - description: Whether the service manages its VPC endpoints. - type: bool - tags: - returned: success - description: A dict of tags associated with the service - type: dict - private_dns_name_verification_state: - returned: success - description: - - The verification state of the VPC endpoint service. - - Consumers of an endpoint service cannot use the private name when the state is not C(verified). - type: str -''' - -try: - 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.core import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ansible_dict_to_boto3_filter_list -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_tag_list_to_ansible_dict -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry - - -# We're using a paginator so we can't use the client decorators -@AWSRetry.jittered_backoff() -def get_services(client, module): - paginator = client.get_paginator('describe_vpc_endpoint_services') - params = {} - if module.params.get("filters"): - params['Filters'] = ansible_dict_to_boto3_filter_list(module.params.get("filters")) - - if module.params.get("service_names"): - params['ServiceNames'] = module.params.get("service_names") - - results = paginator.paginate(**params).build_full_result() - return results - - -def normalize_service(service): - normalized = camel_dict_to_snake_dict(service, ignore_list=['Tags']) - normalized["tags"] = boto3_tag_list_to_ansible_dict(service.get('Tags')) - return normalized - - -def normalize_result(result): - normalized = {} - normalized['service_details'] = [normalize_service(service) for service in result.get('ServiceDetails')] - normalized['service_names'] = result.get('ServiceNames', []) - return normalized - - -def main(): - argument_spec = dict( - filters=dict(default={}, type='dict'), - service_names=dict(type='list', elements='str'), - ) - - module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) - - # Validate Requirements - try: - client = module.client('ec2') - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - module.fail_json_aws(e, msg='Failed to connect to AWS') - - try: - results = get_services(client, module) - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - module.fail_json_aws(e, msg='Failed to connect to retrieve service details') - normalized_result = normalize_result(results) - - module.exit_json(changed=False, **normalized_result) - - -if __name__ == '__main__': - main() diff --git a/tests/integration/targets/ec2_vpc_endpoint/aliases b/tests/integration/targets/ec2_vpc_endpoint/aliases deleted file mode 100644 index 506820fc14b..00000000000 --- a/tests/integration/targets/ec2_vpc_endpoint/aliases +++ /dev/null @@ -1,3 +0,0 @@ -cloud/aws -disabled -ec2_vpc_endpoint_info diff --git a/tests/integration/targets/ec2_vpc_endpoint/defaults/main.yml b/tests/integration/targets/ec2_vpc_endpoint/defaults/main.yml deleted file mode 100644 index f0041c402e5..00000000000 --- a/tests/integration/targets/ec2_vpc_endpoint/defaults/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -vpc_name: '{{ resource_prefix }}-vpc' -vpc_seed: '{{ resource_prefix }}' -vpc_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.22.0/24' - -# S3 and EC2 should generally be available... -endpoint_service_a: 'com.amazonaws.{{ aws_region }}.s3' -endpoint_service_b: 'com.amazonaws.{{ aws_region }}.ec2' diff --git a/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml b/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml deleted file mode 100644 index 0bd2beed8c5..00000000000 --- a/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml +++ /dev/null @@ -1,818 +0,0 @@ ---- -- name: ec2_vpc_endpoint tests - collections: - - amazon.aws - - module_defaults: - group/aws: - aws_access_key: "{{ aws_access_key }}" - aws_secret_key: "{{ aws_secret_key }}" - security_token: "{{ security_token | default(omit) }}" - region: "{{ aws_region }}" - block: - # ============================================================ - # BEGIN PRE-TEST SETUP - - name: create a VPC - ec2_vpc_net: - state: present - name: "{{ vpc_name }}" - cidr_block: "{{ vpc_cidr }}" - tags: - AnsibleTest: 'ec2_vpc_endpoint' - AnsibleRun: '{{ resource_prefix }}' - register: vpc_creation - - name: Assert success - assert: - that: - - vpc_creation is successful - - - name: Create an IGW - ec2_vpc_igw: - vpc_id: "{{ vpc_creation.vpc.id }}" - state: present - tags: - Name: "{{ resource_prefix }}" - AnsibleTest: 'ec2_vpc_endpoint' - AnsibleRun: '{{ resource_prefix }}' - register: igw_creation - - name: Assert success - assert: - that: - - igw_creation is successful - - - name: Create a minimal route table (no routes) - ec2_vpc_route_table: - vpc_id: '{{ vpc_creation.vpc.id }}' - tags: - AnsibleTest: 'ec2_vpc_endpoint' - AnsibleRun: '{{ resource_prefix }}' - Name: '{{ resource_prefix }}-empty' - subnets: [] - routes: [] - register: rtb_creation_empty - - - name: Create a minimal route table (with IGW) - ec2_vpc_route_table: - vpc_id: '{{ vpc_creation.vpc.id }}' - tags: - AnsibleTest: 'ec2_vpc_endpoint' - AnsibleRun: '{{ resource_prefix }}' - Name: '{{ resource_prefix }}-igw' - subnets: [] - routes: - - dest: 0.0.0.0/0 - gateway_id: "{{ igw_creation.gateway_id }}" - register: rtb_creation_igw - - - name: Save VPC info in a fact - set_fact: - vpc_id: '{{ vpc_creation.vpc.id }}' - rtb_empty_id: '{{ rtb_creation_empty.route_table.id }}' - rtb_igw_id: '{{ rtb_creation_igw.route_table.id }}' - - # ============================================================ - # BEGIN TESTS - - # 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 - assert: - that: - # May be run in parallel, the only thing we can guarantee is - # - we shouldn't error - # - we should return 'vpc_endpoints' (even if it's empty) - - 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: - state: present - vpc_id: '{{ vpc_id }}' - service: '{{ endpoint_service_a }}' - register: create_endpoint_check - check_mode: True - - name: Assert changed - assert: - that: - - create_endpoint_check is changed - - - name: Create minimal endpoint - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - service: '{{ endpoint_service_a }}' - wait: true - register: create_endpoint - - name: Check standard return values - assert: - that: - - create_endpoint is changed - - '"result" in create_endpoint' - - '"creation_timestamp" in create_endpoint.result' - - '"dns_entries" in create_endpoint.result' - - '"groups" in create_endpoint.result' - - '"network_interface_ids" in create_endpoint.result' - - '"owner_id" in create_endpoint.result' - - '"policy_document" in create_endpoint.result' - - '"private_dns_enabled" in create_endpoint.result' - - create_endpoint.result.private_dns_enabled == False - - '"requester_managed" in create_endpoint.result' - - create_endpoint.result.requester_managed == False - - '"service_name" in create_endpoint.result' - - create_endpoint.result.service_name == endpoint_service_a - - '"state" in create_endpoint.result' - - create_endpoint.result.state == "available" - - '"vpc_endpoint_id" in create_endpoint.result' - - create_endpoint.result.vpc_endpoint_id.startswith("vpce-") - - '"vpc_endpoint_type" in create_endpoint.result' - - create_endpoint.result.vpc_endpoint_type == "Gateway" - - '"vpc_id" in create_endpoint.result' - - create_endpoint.result.vpc_id == vpc_id - - - name: Save Endpoint info in a fact - set_fact: - endpoint_id: '{{ create_endpoint.result.vpc_endpoint_id }}' - - # Pull info about the endpoints - - name: Fetch Endpoints (all) - ec2_vpc_endpoint_info: - query: endpoints - register: endpoint_info - - name: Assert success - assert: - that: - # We're fetching all endpoints, there's no guarantee what the values - # will be - - endpoint_info is successful - - '"vpc_endpoints" in endpoint_info' - - '"creation_timestamp" in first_endpoint' - - '"policy_document" in first_endpoint' - - '"route_table_ids" in first_endpoint' - - first_endpoint.route_table_ids | length == 0 - - '"service_name" in first_endpoint' - - '"state" in first_endpoint' - - '"vpc_endpoint_id" in first_endpoint' - - '"vpc_id" in first_endpoint' - # Not yet documented, but returned - - '"dns_entries" in first_endpoint' - - '"groups" in first_endpoint' - - '"network_interface_ids" in first_endpoint' - - '"owner_id" in first_endpoint' - - '"private_dns_enabled" in first_endpoint' - - '"requester_managed" in first_endpoint' - - '"subnet_ids" in first_endpoint' - - '"tags" in first_endpoint' - - '"vpc_endpoint_type" in first_endpoint' - # Make sure our endpoint is included - - endpoint_id in ( endpoint_info | community.general.json_query("vpc_endpoints[*].vpc_endpoint_id") | list | flatten ) - vars: - first_endpoint: '{{ endpoint_info.vpc_endpoints[0] }}' - - - name: Fetch Endpoints (targetted by ID) - ec2_vpc_endpoint_info: - query: endpoints - vpc_endpoint_ids: '{{ endpoint_id }}' - register: endpoint_info - - name: Assert success - assert: - that: - - endpoint_info is successful - - '"vpc_endpoints" in endpoint_info' - - '"creation_timestamp" in first_endpoint' - - '"policy_document" in first_endpoint' - - '"route_table_ids" in first_endpoint' - - first_endpoint.route_table_ids | length == 0 - - '"service_name" in first_endpoint' - - first_endpoint.service_name == endpoint_service_a - - '"state" in first_endpoint' - - first_endpoint.state == "available" - - '"vpc_endpoint_id" in first_endpoint' - - first_endpoint.vpc_endpoint_id == endpoint_id - - '"vpc_id" in first_endpoint' - - first_endpoint.vpc_id == vpc_id - # Not yet documented, but returned - - '"dns_entries" in first_endpoint' - - '"groups" in first_endpoint' - - '"network_interface_ids" in first_endpoint' - - '"owner_id" in first_endpoint' - - '"private_dns_enabled" in first_endpoint' - - first_endpoint.private_dns_enabled == False - - '"requester_managed" in first_endpoint' - - first_endpoint.requester_managed == False - - '"subnet_ids" in first_endpoint' - - '"tags" in first_endpoint' - - '"vpc_endpoint_type" in first_endpoint' - vars: - first_endpoint: '{{ endpoint_info.vpc_endpoints[0] }}' - - - name: Fetch Endpoints (targetted by VPC) - ec2_vpc_endpoint_info: - query: endpoints - filters: - vpc-id: - - '{{ vpc_id }}' - register: endpoint_info - - name: Assert success - assert: - that: - - endpoint_info is successful - - '"vpc_endpoints" in endpoint_info' - - '"creation_timestamp" in first_endpoint' - - '"policy_document" in first_endpoint' - - '"route_table_ids" in first_endpoint' - - '"service_name" in first_endpoint' - - first_endpoint.service_name == endpoint_service_a - - '"state" in first_endpoint' - - first_endpoint.state == "available" - - '"vpc_endpoint_id" in first_endpoint' - - first_endpoint.vpc_endpoint_id == endpoint_id - - '"vpc_id" in first_endpoint' - - first_endpoint.vpc_id == vpc_id - # Not yet documented, but returned - - '"dns_entries" in first_endpoint' - - '"groups" in first_endpoint' - - '"network_interface_ids" in first_endpoint' - - '"owner_id" in first_endpoint' - - '"private_dns_enabled" in first_endpoint' - - first_endpoint.private_dns_enabled == False - - '"requester_managed" in first_endpoint' - - first_endpoint.requester_managed == False - - '"subnet_ids" in first_endpoint' - - '"tags" in first_endpoint' - - '"vpc_endpoint_type" in first_endpoint' - vars: - first_endpoint: '{{ endpoint_info.vpc_endpoints[0] }}' - - - # matches on parameters without explicitly passing the endpoint ID - - name: Create minimal endpoint - idempotency (check mode) - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - service: '{{ endpoint_service_a }}' - register: create_endpoint_idem_check - check_mode: True - - assert: - that: - - create_endpoint_idem_check is not changed - - - name: Create minimal endpoint - idempotency - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - service: '{{ endpoint_service_a }}' - register: create_endpoint_idem - - assert: - that: - - create_endpoint_idem is not changed - - - name: Delete minimal endpoint by ID (check_mode) - ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ endpoint_id }}" - check_mode: true - register: endpoint_delete_check - - assert: - that: - - endpoint_delete_check is changed - - - - name: Delete minimal endpoint by ID - ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ endpoint_id }}" - register: endpoint_delete_check - - assert: - that: - - endpoint_delete_check is changed - - - name: Delete minimal endpoint by ID - idempotency (check_mode) - ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ endpoint_id }}" - check_mode: true - register: endpoint_delete_check - - assert: - that: - - endpoint_delete_check is not changed - - - name: Delete minimal endpoint by ID - idempotency - ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ endpoint_id }}" - register: endpoint_delete_check - - assert: - that: - - endpoint_delete_check is not changed - - - name: Fetch Endpoints by ID (expect failed) - ec2_vpc_endpoint_info: - query: endpoints - vpc_endpoint_ids: "{{ endpoint_id }}" - ignore_errors: True - register: endpoint_info - - name: Assert endpoint does not exist - assert: - that: - - endpoint_info is successful - - '"does not exist" in endpoint_info.msg' - - endpoint_info.vpc_endpoints | length == 0 - - # Attempt to create an endpoint with a route table - - name: Create an endpoint with route table (check mode) - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - service: '{{ endpoint_service_a }}' - route_table_ids: - - '{{ rtb_empty_id }}' - register: create_endpoint_check - check_mode: True - - name: Assert changed - assert: - that: - - create_endpoint_check is changed - - - name: Create an endpoint with route table - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - service: '{{ endpoint_service_a }}' - route_table_ids: - - '{{ rtb_empty_id }}' - wait: true - register: create_rtb_endpoint - - name: Check standard return values - assert: - that: - - create_rtb_endpoint is changed - - '"result" in create_rtb_endpoint' - - '"creation_timestamp" in create_rtb_endpoint.result' - - '"dns_entries" in create_rtb_endpoint.result' - - '"groups" in create_rtb_endpoint.result' - - '"network_interface_ids" in create_rtb_endpoint.result' - - '"owner_id" in create_rtb_endpoint.result' - - '"policy_document" in create_rtb_endpoint.result' - - '"private_dns_enabled" in create_rtb_endpoint.result' - - '"route_table_ids" in create_rtb_endpoint.result' - - create_rtb_endpoint.result.route_table_ids | length == 1 - - create_rtb_endpoint.result.route_table_ids[0] == '{{ rtb_empty_id }}' - - create_rtb_endpoint.result.private_dns_enabled == False - - '"requester_managed" in create_rtb_endpoint.result' - - create_rtb_endpoint.result.requester_managed == False - - '"service_name" in create_rtb_endpoint.result' - - create_rtb_endpoint.result.service_name == endpoint_service_a - - '"state" in create_endpoint.result' - - create_rtb_endpoint.result.state == "available" - - '"vpc_endpoint_id" in create_rtb_endpoint.result' - - create_rtb_endpoint.result.vpc_endpoint_id.startswith("vpce-") - - '"vpc_endpoint_type" in create_rtb_endpoint.result' - - create_rtb_endpoint.result.vpc_endpoint_type == "Gateway" - - '"vpc_id" in create_rtb_endpoint.result' - - create_rtb_endpoint.result.vpc_id == vpc_id - - - name: Save Endpoint info in a fact - set_fact: - rtb_endpoint_id: '{{ create_rtb_endpoint.result.vpc_endpoint_id }}' - - - name: Create an endpoint with route table - idempotency (check mode) - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - service: '{{ endpoint_service_a }}' - route_table_ids: - - '{{ rtb_empty_id }}' - register: create_endpoint_check - check_mode: True - - name: Assert changed - assert: - that: - - create_endpoint_check is not changed - - - name: Create an endpoint with route table - idempotency - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - service: '{{ endpoint_service_a }}' - route_table_ids: - - '{{ rtb_empty_id }}' - register: create_endpoint_check - check_mode: True - - name: Assert changed - assert: - that: - - create_endpoint_check is not changed - -# # Endpoint modifications are not yet supported by the module -# # A Change the route table for the endpoint -# - name: Change the route table for the endpoint (check_mode) -# ec2_vpc_endpoint: -# state: present -# vpc_id: '{{ vpc_id }}' -# vpc_endpoint_id: "{{ rtb_endpoint_id }}" -# service: '{{ endpoint_service_a }}' -# route_table_ids: -# - '{{ rtb_igw_id }}' -# check_mode: True -# register: check_two_rtbs_endpoint -# -# - name: Assert second route table would be added -# assert: -# that: -# - check_two_rtbs_endpoint.changed -# -# - name: Change the route table for the endpoint -# ec2_vpc_endpoint: -# state: present -# vpc_id: '{{ vpc_id }}' -# vpc_endpoint_id: "{{ rtb_endpoint_id }}" -# service: '{{ endpoint_service_a }}' -# route_table_ids: -# - '{{ rtb_igw_id }}' -# register: two_rtbs_endpoint -# -# - name: Assert second route table would be added -# assert: -# that: -# - check_two_rtbs_endpoint.changed -# - two_rtbs_endpoint.result.route_table_ids | length == 1 -# - two_rtbs_endpoint.result.route_table_ids[0] == '{{ rtb_igw_id }}' -# -# - name: Change the route table for the endpoint - idempotency (check_mode) -# ec2_vpc_endpoint: -# state: present -# vpc_id: '{{ vpc_id }}' -# vpc_endpoint_id: "{{ rtb_endpoint_id }}" -# service: '{{ endpoint_service_a }}' -# route_table_ids: -# - '{{ rtb_igw_id }}' -# check_mode: True -# register: check_two_rtbs_endpoint -# -# - name: Assert route table would not change -# assert: -# that: -# - not check_two_rtbs_endpoint.changed -# -# - name: Change the route table for the endpoint - idempotency -# ec2_vpc_endpoint: -# state: present -# vpc_id: '{{ vpc_id }}' -# vpc_endpoint_id: "{{ rtb_endpoint_id }}" -# service: '{{ endpoint_service_a }}' -# route_table_ids: -# - '{{ rtb_igw_id }}' -# register: two_rtbs_endpoint -# -# - name: Assert route table would not change -# assert: -# that: -# - not check_two_rtbs_endpoint.changed - - - name: Tag the endpoint (check_mode) - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - vpc_endpoint_id: "{{ rtb_endpoint_id }}" - service: '{{ endpoint_service_a }}' - route_table_ids: - - '{{ rtb_empty_id }}' - tags: - camelCase: "helloWorld" - PascalCase: "HelloWorld" - snake_case: "hello_world" - "Title Case": "Hello World" - "lowercase spaced": "hello world" - check_mode: true - register: check_tag_vpc_endpoint - - - name: Assert tags would have changed - assert: - that: - - check_tag_vpc_endpoint.changed - - - name: Tag the endpoint - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - vpc_endpoint_id: "{{ rtb_endpoint_id }}" - service: '{{ endpoint_service_a }}' - route_table_ids: - - '{{ rtb_igw_id }}' - tags: - testPrefix: '{{ resource_prefix }}' - camelCase: "helloWorld" - PascalCase: "HelloWorld" - snake_case: "hello_world" - "Title Case": "Hello World" - "lowercase spaced": "hello world" - register: tag_vpc_endpoint - - - name: Assert tags are successful - assert: - that: - - tag_vpc_endpoint.changed - - tag_vpc_endpoint.result.tags | length == 6 - - endpoint_tags["testPrefix"] == resource_prefix - - endpoint_tags["camelCase"] == "helloWorld" - - endpoint_tags["PascalCase"] == "HelloWorld" - - endpoint_tags["snake_case"] == "hello_world" - - endpoint_tags["Title Case"] == "Hello World" - - endpoint_tags["lowercase spaced"] == "hello world" - vars: - endpoint_tags: "{{ tag_vpc_endpoint.result.tags | items2dict(key_name='Key', value_name='Value') }}" - - - name: Query by tag - ec2_vpc_endpoint_info: - query: endpoints - filters: - "tag:testPrefix": - - "{{ resource_prefix }}" - register: tag_result - - - name: Assert tag lookup found endpoint - assert: - that: - - tag_result is successful - - '"vpc_endpoints" in tag_result' - - first_endpoint.vpc_endpoint_id == rtb_endpoint_id - vars: - first_endpoint: '{{ tag_result.vpc_endpoints[0] }}' - - - name: Tag the endpoint - idempotency (check_mode) - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - vpc_endpoint_id: "{{ rtb_endpoint_id }}" - service: '{{ endpoint_service_a }}' - route_table_ids: - - '{{ rtb_igw_id }}' - tags: - testPrefix: '{{ resource_prefix }}' - camelCase: "helloWorld" - PascalCase: "HelloWorld" - snake_case: "hello_world" - "Title Case": "Hello World" - "lowercase spaced": "hello world" - register: tag_vpc_endpoint_again - - - name: Assert tags would not change - assert: - that: - - not tag_vpc_endpoint_again.changed - - - name: Tag the endpoint - idempotency - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - vpc_endpoint_id: "{{ rtb_endpoint_id }}" - service: '{{ endpoint_service_a }}' - route_table_ids: - - '{{ rtb_igw_id }}' - tags: - testPrefix: '{{ resource_prefix }}' - camelCase: "helloWorld" - PascalCase: "HelloWorld" - snake_case: "hello_world" - "Title Case": "Hello World" - "lowercase spaced": "hello world" - register: tag_vpc_endpoint_again - - - name: Assert tags would not change - assert: - that: - - not tag_vpc_endpoint_again.changed - - - name: Add a tag (check_mode) - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - vpc_endpoint_id: "{{ rtb_endpoint_id }}" - service: '{{ endpoint_service_a }}' - route_table_ids: - - '{{ rtb_igw_id }}' - tags: - new_tag: "ANewTag" - check_mode: true - register: check_tag_vpc_endpoint - - - name: Assert tags would have changed - assert: - that: - - check_tag_vpc_endpoint.changed - - - name: Add a tag (purge_tags=False) - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - vpc_endpoint_id: "{{ rtb_endpoint_id }}" - service: '{{ endpoint_service_a }}' - route_table_ids: - - '{{ rtb_igw_id }}' - tags: - new_tag: "ANewTag" - register: add_tag_vpc_endpoint - - - name: Assert tags changed - assert: - that: - - add_tag_vpc_endpoint.changed - - add_tag_vpc_endpoint.result.tags | length == 7 - - endpoint_tags["testPrefix"] == resource_prefix - - endpoint_tags["camelCase"] == "helloWorld" - - endpoint_tags["PascalCase"] == "HelloWorld" - - endpoint_tags["snake_case"] == "hello_world" - - endpoint_tags["Title Case"] == "Hello World" - - endpoint_tags["lowercase spaced"] == "hello world" - - endpoint_tags["new_tag"] == "ANewTag" - vars: - endpoint_tags: "{{ add_tag_vpc_endpoint.result.tags | items2dict(key_name='Key', value_name='Value') }}" - - - name: Add a tag (purge_tags=True) - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - vpc_endpoint_id: "{{ rtb_endpoint_id }}" - service: '{{ endpoint_service_a }}' - route_table_ids: - - '{{ rtb_igw_id }}' - tags: - another_new_tag: "AnotherNewTag" - purge_tags: True - register: purge_tag_vpc_endpoint - - - name: Assert tags changed - assert: - that: - - purge_tag_vpc_endpoint.changed - - purge_tag_vpc_endpoint.result.tags | length == 1 - - endpoint_tags["another_new_tag"] == "AnotherNewTag" - vars: - endpoint_tags: "{{ purge_tag_vpc_endpoint.result.tags | items2dict(key_name='Key', value_name='Value') }}" - - - name: Delete minimal route table (no routes) - ec2_vpc_route_table: - state: absent - lookup: id - route_table_id: "{{ rtb_empty_id }}" - register: rtb_delete - - assert: - that: - - rtb_delete is changed - - - name: Delete minimal route table (IGW route) - ec2_vpc_route_table: - state: absent - lookup: id - route_table_id: "{{ rtb_igw_id }}" - - assert: - that: - - rtb_delete is changed - - - name: Delete route table endpoint by ID - ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ rtb_endpoint_id }}" - register: endpoint_delete_check - - assert: - that: - - endpoint_delete_check is changed - - - name: Delete minimal endpoint by ID - idempotency (check_mode) - ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ rtb_endpoint_id }}" - check_mode: true - register: endpoint_delete_check - - assert: - that: - - endpoint_delete_check is not changed - - - name: Delete endpoint by ID - idempotency - ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ endpoint_id }}" - register: endpoint_delete_check - - assert: - that: - - endpoint_delete_check is not changed - - - name: Create interface endpoint - ec2_vpc_endpoint: - state: present - vpc_id: '{{ vpc_id }}' - service: '{{ endpoint_service_a }}' - vpc_endpoint_type: Interface - register: create_interface_endpoint - - name: Check that the interface endpoint was created properly - assert: - that: - - create_interface_endpoint is changed - - create_interface_endpoint.result.vpc_endpoint_type == "Interface" - - name: Delete interface endpoint - ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ create_interface_endpoint.result.vpc_endpoint_id }}" - register: interface_endpoint_delete_check - - assert: - that: - - interface_endpoint_delete_check is changed - - # ============================================================ - # BEGIN POST-TEST CLEANUP - always: - # Delete the routes first - you can't delete an endpoint with a route - # attached. - - name: Delete minimal route table (no routes) - ec2_vpc_route_table: - state: absent - lookup: id - route_table_id: "{{ rtb_creation_empty.route_table.id }}" - ignore_errors: True - - - name: Delete minimal route table (IGW route) - ec2_vpc_route_table: - state: absent - lookup: id - route_table_id: "{{ rtb_creation_igw.route_table.id }}" - ignore_errors: True - - - name: Delete endpoint - ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ create_endpoint.result.vpc_endpoint_id }}" - ignore_errors: True - - - name: Delete endpoint - ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: "{{ create_rtb_endpoint.result.vpc_endpoint_id }}" - ignore_errors: True - - - name: Query any remain endpoints we created (idempotency work is ongoing) # FIXME - ec2_vpc_endpoint_info: - query: endpoints - filters: - vpc-id: - - '{{ vpc_id }}' - register: test_endpoints - - - name: Delete all endpoints - ec2_vpc_endpoint: - state: absent - vpc_endpoint_id: '{{ item.vpc_endpoint_id }}' - with_items: '{{ test_endpoints.vpc_endpoints }}' - ignore_errors: True - - - name: Remove IGW - ec2_vpc_igw: - state: absent - vpc_id: "{{ vpc_id }}" - register: igw_deletion - retries: 10 - delay: 5 - until: igw_deletion is success - ignore_errors: yes - - - name: Remove VPC - ec2_vpc_net: - state: absent - name: "{{ vpc_name }}" - cidr_block: "{{ vpc_cidr }}" - ignore_errors: true diff --git a/tests/integration/targets/ec2_vpc_endpoint_service_info/aliases b/tests/integration/targets/ec2_vpc_endpoint_service_info/aliases deleted file mode 100644 index 760a04f5d2b..00000000000 --- a/tests/integration/targets/ec2_vpc_endpoint_service_info/aliases +++ /dev/null @@ -1,2 +0,0 @@ -cloud/aws -ec2_vpc_endpoint_service_info diff --git a/tests/integration/targets/ec2_vpc_endpoint_service_info/defaults/main.yml b/tests/integration/targets/ec2_vpc_endpoint_service_info/defaults/main.yml deleted file mode 100644 index 445cc7f3c52..00000000000 --- a/tests/integration/targets/ec2_vpc_endpoint_service_info/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -search_service_names: -- 'com.amazonaws.{{ aws_region }}.s3' -- 'com.amazonaws.{{ aws_region }}.ec2' diff --git a/tests/integration/targets/ec2_vpc_endpoint_service_info/meta/main.yml b/tests/integration/targets/ec2_vpc_endpoint_service_info/meta/main.yml deleted file mode 100644 index 1810d4bec98..00000000000 --- a/tests/integration/targets/ec2_vpc_endpoint_service_info/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - setup_remote_tmp_dir diff --git a/tests/integration/targets/ec2_vpc_endpoint_service_info/tasks/main.yml b/tests/integration/targets/ec2_vpc_endpoint_service_info/tasks/main.yml deleted file mode 100644 index 22b290a34ff..00000000000 --- a/tests/integration/targets/ec2_vpc_endpoint_service_info/tasks/main.yml +++ /dev/null @@ -1,135 +0,0 @@ ---- -- module_defaults: - group/aws: - aws_access_key: '{{ aws_access_key }}' - aws_secret_key: '{{ aws_secret_key }}' - security_token: '{{ security_token | default(omit) }}' - region: '{{ aws_region }}' - collections: - - amazon.aws - - community.aws - block: - - - name: 'List all available services (Check Mode)' - ec2_vpc_endpoint_service_info: - check_mode: True - register: services_check - - - name: 'Verify services (Check Mode)' - vars: - first_service: '{{ services_check.service_details[0] }}' - assert: - that: - - services_check is successful - - services_check is not changed - - '"service_names" in services_check' - - '"service_details" in services_check' - - '"acceptance_required" in first_service' - - '"availability_zones" in first_service' - - '"base_endpoint_dns_names" in first_service' - - '"manages_vpc_endpoints" in first_service' - - '"owner" in first_service' - - '"private_dns_name" in first_service' - - '"private_dns_name_verification_state" in first_service' - - '"service_id" in first_service' - - '"service_name" in first_service' - - '"service_type" in first_service' - - '"tags" in first_service' - - '"vpc_endpoint_policy_supported" in first_service' - - - name: 'List all available services' - ec2_vpc_endpoint_service_info: - register: services_info - - - name: 'Verify services' - vars: - first_service: '{{ services_info.service_details[0] }}' - assert: - that: - - services_info is successful - - services_info is not changed - - '"service_names" in services_info' - - '"service_details" in services_info' - - '"acceptance_required" in first_service' - - '"availability_zones" in first_service' - - '"base_endpoint_dns_names" in first_service' - - '"manages_vpc_endpoints" in first_service' - - '"owner" in first_service' - - '"private_dns_name" in first_service' - - '"private_dns_name_verification_state" in first_service' - - '"service_id" in first_service' - - '"service_name" in first_service' - - '"service_type" in first_service' - - '"tags" in first_service' - - '"vpc_endpoint_policy_supported" in first_service' - - - name: 'Limit services by name' - ec2_vpc_endpoint_service_info: - service_names: '{{ search_service_names }}' - register: services_info - - - name: 'Verify services' - vars: - first_service: '{{ services_info.service_details[0] }}' - # The same service sometimes pop up twice. s3 for example has - # s3.us-east-1.amazonaws.com and s3.us-east-1.vpce.amazonaws.com which are - # part of com.amazonaws.us-east-1.s3 so we need to run the results through - # the unique filter to know if we've got what we think we have - unique_names: '{{ services_info.service_names | unique | list }}' - unique_detail_names: '{{ services_info.service_details | map(attribute="service_name") | unique | list }}' - assert: - that: - - services_info is successful - - services_info is not changed - - '"service_names" in services_info' - - (unique_names | length) == (search_service_names | length) - - (unique_detail_names | length ) == (search_service_names | length) - - (unique_names | difference(search_service_names) | length) == 0 - - (unique_detail_names | difference(search_service_names) | length) == 0 - - '"service_details" in services_info' - - '"acceptance_required" in first_service' - - '"availability_zones" in first_service' - - '"base_endpoint_dns_names" in first_service' - - '"manages_vpc_endpoints" in first_service' - - '"owner" in first_service' - - '"private_dns_name" in first_service' - - '"private_dns_name_verification_state" in first_service' - - '"service_id" in first_service' - - '"service_name" in first_service' - - '"service_type" in first_service' - - '"tags" in first_service' - - '"vpc_endpoint_policy_supported" in first_service' - - - name: 'Grab single service details to test filters' - set_fact: - example_service: '{{ services_info.service_details[0] }}' - - - name: 'Limit services by filter' - ec2_vpc_endpoint_service_info: - filters: - service-name: '{{ example_service.service_name }}' - register: filtered_service - - - name: 'Verify services' - vars: - first_service: '{{ filtered_service.service_details[0] }}' - assert: - that: - - filtered_service is successful - - filtered_service is not changed - - '"service_names" in filtered_service' - - filtered_service.service_names | length == 1 - - '"service_details" in filtered_service' - - filtered_service.service_details | length == 1 - - '"acceptance_required" in first_service' - - '"availability_zones" in first_service' - - '"base_endpoint_dns_names" in first_service' - - '"manages_vpc_endpoints" in first_service' - - '"owner" in first_service' - - '"private_dns_name" in first_service' - - '"private_dns_name_verification_state" in first_service' - - '"service_id" in first_service' - - '"service_name" in first_service' - - '"service_type" in first_service' - - '"tags" in first_service' - - '"vpc_endpoint_policy_supported" in first_service' diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt index 8eef080dc80..ba2989f08c6 100644 --- a/tests/sanity/ignore-2.9.txt +++ b/tests/sanity/ignore-2.9.txt @@ -15,8 +15,6 @@ plugins/modules/ec2_elb_info.py validate-modules:invalid-documentation # Ansibl plugins/modules/ec2_lc_info.py pylint:ansible-deprecated-no-version plugins/modules/ec2_metric_alarm.py pylint:ansible-deprecated-no-version plugins/modules/ec2_placement_group_info.py pylint:ansible-deprecated-no-version -plugins/modules/ec2_vpc_endpoint.py pylint:ansible-deprecated-no-version -plugins/modules/ec2_vpc_endpoint_info.py pylint:ansible-deprecated-no-version plugins/modules/ec2_vpc_igw_info.py pylint:ansible-deprecated-no-version plugins/modules/ec2_vpc_nacl_info.py pylint:ansible-deprecated-no-version plugins/modules/ec2_vpc_peering_info.py pylint:ansible-deprecated-no-version