From 4c575b192eb814a11de53a39dfec5ae7472a7c47 Mon Sep 17 00:00:00 2001 From: Jill Rouleau Date: Tue, 27 Jul 2021 14:00:13 -0700 Subject: [PATCH 1/3] Remove modules --- .../community.aws.ec2_vpc_igw_info_module.rst | 464 -------------- docs/community.aws.ec2_vpc_igw_module.rst | 430 ------------- plugins/modules/ec2_vpc_igw.py | 291 --------- plugins/modules/ec2_vpc_igw_facts.py | 1 - plugins/modules/ec2_vpc_igw_info.py | 184 ------ tests/integration/targets/ec2_vpc_igw/aliases | 3 - .../targets/ec2_vpc_igw/defaults/main.yml | 4 - .../targets/ec2_vpc_igw/tasks/main.yml | 571 ------------------ 8 files changed, 1948 deletions(-) delete mode 100644 docs/community.aws.ec2_vpc_igw_info_module.rst delete mode 100644 docs/community.aws.ec2_vpc_igw_module.rst delete mode 100644 plugins/modules/ec2_vpc_igw.py delete mode 120000 plugins/modules/ec2_vpc_igw_facts.py delete mode 100644 plugins/modules/ec2_vpc_igw_info.py delete mode 100644 tests/integration/targets/ec2_vpc_igw/aliases delete mode 100644 tests/integration/targets/ec2_vpc_igw/defaults/main.yml delete mode 100644 tests/integration/targets/ec2_vpc_igw/tasks/main.yml diff --git a/docs/community.aws.ec2_vpc_igw_info_module.rst b/docs/community.aws.ec2_vpc_igw_info_module.rst deleted file mode 100644 index 0aa0c6313ee..00000000000 --- a/docs/community.aws.ec2_vpc_igw_info_module.rst +++ /dev/null @@ -1,464 +0,0 @@ -.. _community.aws.ec2_vpc_igw_info_module: - - -****************************** -community.aws.ec2_vpc_igw_info -****************************** - -**Gather information about internet gateways in AWS** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - - -Synopsis --------- -- Gather information about internet gateways in AWS. -- This module was called ``ec2_vpc_igw_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.
- -
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
-
-
- convert_tags - -
- boolean -
-
added in 1.3.0
-
-
    Choices: -
  • no
  • -
  • yes
  • -
-
-
Convert tags from boto3 format (list of dictionaries) to the standard dictionary format.
-
This currently defaults to False. The default will be changed to True after 2022-06-22.
-
-
- 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_DescribeInternetGateways.html for possible filters.
-
-
- internet_gateway_ids - -
- list - / elements=string -
-
- -
Get details of specific Internet Gateway ID. Provide this value as a list.
-
-
- 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
-
-
- 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 - - # # Note: These examples do not set authentication details, see the AWS Guide for details. - - - name: Gather information about all Internet Gateways for an account or profile - community.aws.ec2_vpc_igw_info: - region: ap-southeast-2 - profile: production - register: igw_info - - - name: Gather information about a filtered list of Internet Gateways - community.aws.ec2_vpc_igw_info: - region: ap-southeast-2 - profile: production - filters: - "tag:Name": "igw-123" - register: igw_info - - - name: Gather information about a specific internet gateway by InternetGatewayId - community.aws.ec2_vpc_igw_info: - region: ap-southeast-2 - profile: production - internet_gateway_ids: igw-c1231234 - register: igw_info - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KeyReturnedDescription
-
- changed - -
- boolean -
-
always -
True if listing the internet gateways succeeds.
-
-
Sample:
-
false
-
-
- internet_gateways - -
- complex -
-
always -
The internet gateways for the account.
-
-
  -
- attachments - -
- complex -
-
state=present -
Any VPCs attached to the internet gateway
-
-
   -
- state - -
- string -
-
state=present -
The current state of the attachment
-
-
Sample:
-
available
-
   -
- vpc_id - -
- string -
-
state=present -
The ID of the VPC.
-
-
Sample:
-
vpc-02123b67
-
  -
- internet_gateway_id - -
- string -
-
state=present -
The ID of the internet gateway
-
-
Sample:
-
igw-2123634d
-
  -
- tags - -
- dictionary -
-
state=present -
Any tags assigned to the internet gateway
-
-
Sample:
-
{'tags': {'Ansible': 'Test'}}
-
-

- - -Status ------- - - -Authors -~~~~~~~ - -- Nick Aslanidis (@naslanidis) diff --git a/docs/community.aws.ec2_vpc_igw_module.rst b/docs/community.aws.ec2_vpc_igw_module.rst deleted file mode 100644 index 73760706b9c..00000000000 --- a/docs/community.aws.ec2_vpc_igw_module.rst +++ /dev/null @@ -1,430 +0,0 @@ -.. _community.aws.ec2_vpc_igw_module: - - -************************* -community.aws.ec2_vpc_igw -************************* - -**Manage an AWS VPC Internet gateway** - - -Version added: 1.0.0 - -.. contents:: - :local: - :depth: 1 - - -Synopsis --------- -- Manage an AWS VPC Internet gateway - - - -Requirements ------------- -The below requirements are needed on the host that executes this module. - -- boto -- boto3 -- botocore -- 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
-
-
- 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.3.0
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
Remove tags not listed in tags.
-
-
- 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
-
-
- state - -
- string -
-
-
    Choices: -
  • present ←
  • -
  • absent
  • -
-
-
Create or terminate the IGW
-
-
- tags - -
- dictionary -
-
- -
A dict of tags to apply to the internet gateway.
-
To remove all tags set tags={} and purge_tags=true.
-

aliases: resource_tags
-
-
- validate_certs - -
- boolean -
-
-
    Choices: -
  • no
  • -
  • yes ←
  • -
-
-
When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0.
-
-
- vpc_id - -
- string - / required -
-
- -
The VPC ID for the VPC in which to manage the Internet Gateway.
-
-
- - -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. - - # Ensure that the VPC has an Internet Gateway. - # The Internet Gateway ID is can be accessed via {{igw.gateway_id}} for use in setting up NATs etc. - - name: Create Internet gateway - community.aws.ec2_vpc_igw: - vpc_id: vpc-abcdefgh - state: present - register: igw - - - name: Create Internet gateway with tags - community.aws.ec2_vpc_igw: - vpc_id: vpc-abcdefgh - state: present - tags: - Tag1: tag1 - Tag2: tag2 - register: igw - - - name: Delete Internet gateway - community.aws.ec2_vpc_igw: - state: absent - vpc_id: vpc-abcdefgh - register: vpc_igw_delete - - - -Return Values -------------- -Common return values are documented `here `_, the following are the fields unique to this module: - -.. raw:: html - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KeyReturnedDescription
-
- changed - -
- boolean -
-
always -
If any changes have been made to the Internet Gateway.
-
-
Sample:
-
{'changed': False}
-
-
- gateway_id - -
- string -
-
state=present -
The unique identifier for the Internet Gateway.
-
-
Sample:
-
{'gateway_id': 'igw-XXXXXXXX'}
-
-
- tags - -
- dictionary -
-
state=present -
The tags associated the Internet Gateway.
-
-
Sample:
-
{'tags': {'Ansible': 'Test'}}
-
-
- vpc_id - -
- string -
-
state=present -
The VPC ID associated with the Internet Gateway.
-
-
Sample:
-
{'vpc_id': 'vpc-XXXXXXXX'}
-
-

- - -Status ------- - - -Authors -~~~~~~~ - -- Robert Estelle (@erydo) diff --git a/plugins/modules/ec2_vpc_igw.py b/plugins/modules/ec2_vpc_igw.py deleted file mode 100644 index c578df12939..00000000000 --- a/plugins/modules/ec2_vpc_igw.py +++ /dev/null @@ -1,291 +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 = ''' ---- -module: ec2_vpc_igw -version_added: 1.0.0 -short_description: Manage an AWS VPC Internet gateway -description: - - Manage an AWS VPC Internet gateway -author: Robert Estelle (@erydo) -options: - vpc_id: - description: - - The VPC ID for the VPC in which to manage the Internet Gateway. - required: true - 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). - aliases: [ 'resource_tags' ] - type: dict - purge_tags: - description: - - Remove tags not listed in I(tags). - type: bool - default: true - version_added: 1.3.0 - state: - description: - - Create or terminate the IGW - default: present - choices: [ 'present', 'absent' ] - type: str -extends_documentation_fragment: -- amazon.aws.aws -- amazon.aws.ec2 -''' - -EXAMPLES = ''' -# Note: These examples do not set authentication details, see the AWS Guide for details. - -# Ensure that the VPC has an Internet Gateway. -# The Internet Gateway ID is can be accessed via {{igw.gateway_id}} for use in setting up NATs etc. -- name: Create Internet gateway - community.aws.ec2_vpc_igw: - vpc_id: vpc-abcdefgh - state: present - register: igw - -- name: Create Internet gateway with tags - community.aws.ec2_vpc_igw: - vpc_id: vpc-abcdefgh - state: present - tags: - Tag1: tag1 - Tag2: tag2 - register: igw - -- name: Delete Internet gateway - community.aws.ec2_vpc_igw: - state: absent - vpc_id: vpc-abcdefgh - register: vpc_igw_delete -''' - -RETURN = ''' -changed: - description: If any changes have been made to the Internet Gateway. - type: bool - returned: always - sample: - changed: false -gateway_id: - description: The unique identifier for the Internet Gateway. - type: str - returned: I(state=present) - sample: - gateway_id: "igw-XXXXXXXX" -tags: - description: The tags associated the Internet Gateway. - type: dict - returned: I(state=present) - sample: - tags: - "Ansible": "Test" -vpc_id: - description: The VPC ID associated with the Internet Gateway. - type: str - returned: I(state=present) - sample: - vpc_id: "vpc-XXXXXXXX" -''' - -try: - import botocore -except ImportError: - pass # caught by AnsibleAWSModule - -from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule -from ansible_collections.amazon.aws.plugins.module_utils.waiters import get_waiter -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 camel_dict_to_snake_dict -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import compare_aws_tags - - -class AnsibleEc2Igw(object): - - def __init__(self, module, results): - self._module = module - self._results = results - self._connection = self._module.client('ec2', retry_decorator=AWSRetry.jittered_backoff()) - self._check_mode = self._module.check_mode - - def process(self): - vpc_id = self._module.params.get('vpc_id') - state = self._module.params.get('state', 'present') - tags = self._module.params.get('tags') - purge_tags = self._module.params.get('purge_tags') - - if state == 'present': - self.ensure_igw_present(vpc_id, tags, purge_tags) - elif state == 'absent': - self.ensure_igw_absent(vpc_id) - - def get_matching_igw(self, vpc_id): - filters = ansible_dict_to_boto3_filter_list({'attachment.vpc-id': vpc_id}) - igws = [] - try: - response = self._connection.describe_internet_gateways(aws_retry=True, Filters=filters) - igws = response.get('InternetGateways', []) - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - self._module.fail_json_aws(e) - - igw = None - if len(igws) > 1: - self._module.fail_json( - msg='EC2 returned more than one Internet Gateway for VPC {0}, aborting'.format(vpc_id)) - elif igws: - igw = camel_dict_to_snake_dict(igws[0]) - - return igw - - def ensure_tags(self, igw_id, tags, purge_tags): - final_tags = [] - - filters = ansible_dict_to_boto3_filter_list({'resource-id': igw_id, 'resource-type': 'internet-gateway'}) - cur_tags = None - try: - cur_tags = self._connection.describe_tags(aws_retry=True, Filters=filters) - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - self._module.fail_json_aws(e, msg="Couldn't describe tags") - - if tags is None: - return boto3_tag_list_to_ansible_dict(cur_tags.get('Tags')) - - to_update, to_delete = compare_aws_tags(boto3_tag_list_to_ansible_dict(cur_tags.get('Tags')), tags, purge_tags) - final_tags = boto3_tag_list_to_ansible_dict(cur_tags.get('Tags')) - - if to_update: - try: - if self._check_mode: - final_tags.update(to_update) - else: - self._connection.create_tags( - aws_retry=True, - Resources=[igw_id], - Tags=ansible_dict_to_boto3_tag_list(to_update) - ) - - self._results['changed'] = True - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - self._module.fail_json_aws(e, msg="Couldn't create tags") - - if to_delete: - try: - if self._check_mode: - for key in to_delete: - del final_tags[key] - else: - tags_list = [] - for key in to_delete: - tags_list.append({'Key': key}) - - self._connection.delete_tags(aws_retry=True, Resources=[igw_id], Tags=tags_list) - - self._results['changed'] = True - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - self._module.fail_json_aws(e, msg="Couldn't delete tags") - - if not self._check_mode and (to_update or to_delete): - try: - response = self._connection.describe_tags(aws_retry=True, Filters=filters) - final_tags = boto3_tag_list_to_ansible_dict(response.get('Tags')) - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - self._module.fail_json_aws(e, msg="Couldn't describe tags") - - return final_tags - - @staticmethod - def get_igw_info(igw): - return { - 'gateway_id': igw['internet_gateway_id'], - 'tags': igw['tags'], - 'vpc_id': igw['vpc_id'] - } - - def ensure_igw_absent(self, vpc_id): - igw = self.get_matching_igw(vpc_id) - if igw is None: - return self._results - - if self._check_mode: - self._results['changed'] = True - return self._results - - try: - self._results['changed'] = True - self._connection.detach_internet_gateway(aws_retry=True, InternetGatewayId=igw['internet_gateway_id'], VpcId=vpc_id) - self._connection.delete_internet_gateway(aws_retry=True, InternetGatewayId=igw['internet_gateway_id']) - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - self._module.fail_json_aws(e, msg="Unable to delete Internet Gateway") - - return self._results - - def ensure_igw_present(self, vpc_id, tags, purge_tags): - igw = self.get_matching_igw(vpc_id) - - if igw is None: - if self._check_mode: - self._results['changed'] = True - self._results['gateway_id'] = None - return self._results - - try: - response = self._connection.create_internet_gateway(aws_retry=True) - - # Ensure the gateway exists before trying to attach it or add tags - waiter = get_waiter(self._connection, 'internet_gateway_exists') - waiter.wait(InternetGatewayIds=[response['InternetGateway']['InternetGatewayId']]) - - igw = camel_dict_to_snake_dict(response['InternetGateway']) - self._connection.attach_internet_gateway(aws_retry=True, InternetGatewayId=igw['internet_gateway_id'], VpcId=vpc_id) - self._results['changed'] = True - except botocore.exceptions.WaiterError as e: - self._module.fail_json_aws(e, msg="No Internet Gateway exists.") - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - self._module.fail_json_aws(e, msg='Unable to create Internet Gateway') - - igw['vpc_id'] = vpc_id - - igw['tags'] = self.ensure_tags(igw_id=igw['internet_gateway_id'], tags=tags, purge_tags=purge_tags) - - igw_info = self.get_igw_info(igw) - self._results.update(igw_info) - - return self._results - - -def main(): - argument_spec = dict( - vpc_id=dict(required=True), - state=dict(default='present', choices=['present', 'absent']), - tags=dict(required=False, type='dict', aliases=['resource_tags']), - purge_tags=dict(default=True, type='bool'), - ) - - module = AnsibleAWSModule( - argument_spec=argument_spec, - supports_check_mode=True, - ) - results = dict( - changed=False - ) - igw_manager = AnsibleEc2Igw(module=module, results=results) - igw_manager.process() - - module.exit_json(**results) - - -if __name__ == '__main__': - main() diff --git a/plugins/modules/ec2_vpc_igw_facts.py b/plugins/modules/ec2_vpc_igw_facts.py deleted file mode 120000 index b3eeb3fee6e..00000000000 --- a/plugins/modules/ec2_vpc_igw_facts.py +++ /dev/null @@ -1 +0,0 @@ -ec2_vpc_igw_info.py \ No newline at end of file diff --git a/plugins/modules/ec2_vpc_igw_info.py b/plugins/modules/ec2_vpc_igw_info.py deleted file mode 100644 index 00ecac957ab..00000000000 --- a/plugins/modules/ec2_vpc_igw_info.py +++ /dev/null @@ -1,184 +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_igw_info -version_added: 1.0.0 -short_description: Gather information about internet gateways in AWS -description: - - Gather information about internet gateways in AWS. - - This module was called C(ec2_vpc_igw_facts) before Ansible 2.9. The usage did not change. -author: "Nick Aslanidis (@naslanidis)" -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_DescribeInternetGateways.html) for possible filters. - type: dict - internet_gateway_ids: - description: - - Get details of specific Internet Gateway ID. Provide this value as a list. - type: list - elements: str - convert_tags: - description: - - Convert tags from boto3 format (list of dictionaries) to the standard dictionary format. - - This currently defaults to C(False). The default will be changed to C(True) after 2022-06-22. - type: bool - version_added: 1.3.0 -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: Gather information about all Internet Gateways for an account or profile - community.aws.ec2_vpc_igw_info: - region: ap-southeast-2 - profile: production - register: igw_info - -- name: Gather information about a filtered list of Internet Gateways - community.aws.ec2_vpc_igw_info: - region: ap-southeast-2 - profile: production - filters: - "tag:Name": "igw-123" - register: igw_info - -- name: Gather information about a specific internet gateway by InternetGatewayId - community.aws.ec2_vpc_igw_info: - region: ap-southeast-2 - profile: production - internet_gateway_ids: igw-c1231234 - register: igw_info -''' - -RETURN = r''' -changed: - description: True if listing the internet gateways succeeds. - type: bool - returned: always - sample: "false" -internet_gateways: - description: The internet gateways for the account. - returned: always - type: complex - contains: - attachments: - description: Any VPCs attached to the internet gateway - returned: I(state=present) - type: complex - contains: - state: - description: The current state of the attachment - returned: I(state=present) - type: str - sample: available - vpc_id: - description: The ID of the VPC. - returned: I(state=present) - type: str - sample: vpc-02123b67 - internet_gateway_id: - description: The ID of the internet gateway - returned: I(state=present) - type: str - sample: igw-2123634d - tags: - description: Any tags assigned to the internet gateway - returned: I(state=present) - type: dict - sample: - tags: - "Ansible": "Test" -''' - -try: - import botocore -except ImportError: - pass # Handled by AnsibleAWSModule - -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.ec2 import AWSRetry -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 ansible_dict_to_boto3_filter_list -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import camel_dict_to_snake_dict - - -def get_internet_gateway_info(internet_gateway, convert_tags): - if convert_tags: - tags = boto3_tag_list_to_ansible_dict(internet_gateway['Tags']) - ignore_list = ["Tags"] - else: - tags = internet_gateway['Tags'] - ignore_list = [] - internet_gateway_info = {'InternetGatewayId': internet_gateway['InternetGatewayId'], - 'Attachments': internet_gateway['Attachments'], - 'Tags': tags} - - internet_gateway_info = camel_dict_to_snake_dict(internet_gateway_info, ignore_list=ignore_list) - return internet_gateway_info - - -def list_internet_gateways(connection, module): - params = dict() - - params['Filters'] = ansible_dict_to_boto3_filter_list(module.params.get('filters')) - convert_tags = module.params.get('convert_tags') - - if module.params.get("internet_gateway_ids"): - params['InternetGatewayIds'] = module.params.get("internet_gateway_ids") - - try: - all_internet_gateways = connection.describe_internet_gateways(aws_retry=True, **params) - except is_boto3_error_code('InvalidInternetGatewayID.NotFound'): - module.fail_json('InternetGateway not found') - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: # pylint: disable=duplicate-except - module.fail_json_aws(e, 'Unable to describe internet gateways') - - return [get_internet_gateway_info(igw, convert_tags) - for igw in all_internet_gateways['InternetGateways']] - - -def main(): - argument_spec = dict( - filters=dict(type='dict', default=dict()), - internet_gateway_ids=dict(type='list', default=None, elements='str'), - convert_tags=dict(type='bool'), - ) - - module = AnsibleAWSModule(argument_spec=argument_spec, supports_check_mode=True) - if module._name == 'ec2_vpc_igw_facts': - module.deprecate("The 'ec2_vpc_igw_facts' module has been renamed to 'ec2_vpc_igw_info'", date='2021-12-01', collection_name='community.aws') - - if module.params.get('convert_tags') is None: - module.deprecate('This module currently returns boto3 style tags by default. ' - 'This default has been deprecated and the module will return a simple dictionary in future. ' - 'This behaviour can be controlled through the convert_tags parameter.', - date='2021-12-01', collection_name='community.aws') - - # Validate Requirements - try: - connection = 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') - - # call your function here - results = list_internet_gateways(connection, module) - - module.exit_json(internet_gateways=results) - - -if __name__ == '__main__': - main() diff --git a/tests/integration/targets/ec2_vpc_igw/aliases b/tests/integration/targets/ec2_vpc_igw/aliases deleted file mode 100644 index 877a442d752..00000000000 --- a/tests/integration/targets/ec2_vpc_igw/aliases +++ /dev/null @@ -1,3 +0,0 @@ -cloud/aws - -ec2_vpc_igw_info diff --git a/tests/integration/targets/ec2_vpc_igw/defaults/main.yml b/tests/integration/targets/ec2_vpc_igw/defaults/main.yml deleted file mode 100644 index eeda091c81c..00000000000 --- a/tests/integration/targets/ec2_vpc_igw/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -vpc_name: '{{ resource_prefix }}-vpc' -vpc_seed: '{{ resource_prefix }}' -vpc_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.0.0/16' diff --git a/tests/integration/targets/ec2_vpc_igw/tasks/main.yml b/tests/integration/targets/ec2_vpc_igw/tasks/main.yml deleted file mode 100644 index 6697493127d..00000000000 --- a/tests/integration/targets/ec2_vpc_igw/tasks/main.yml +++ /dev/null @@ -1,571 +0,0 @@ ---- -- name: ec2_vpc_igw 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: - # ============================================================ - - name: Fetch IGWs in check_mode - ec2_vpc_igw_info: - register: igw_info - check_mode: True - - - name: Assert success - assert: - that: - - igw_info is successful - - '"internet_gateways" in igw_info' - - # ============================================================ - - name: create a VPC - ec2_vpc_net: - name: "{{ vpc_name }}" - state: present - cidr_block: "{{ vpc_cidr }}" - tags: - Name: "{{ resource_prefix }}-vpc" - Description: "Created by ansible-test" - register: vpc_result - - - name: Assert success - assert: - that: - - vpc_result is successful - - '"vpc" in vpc_result' - - '"id" in vpc_result.vpc' - - vpc_result.vpc.state == 'available' - - '"tags" in vpc_result.vpc' - - vpc_result.vpc.tags | length == 2 - - vpc_result.vpc.tags["Name"] == "{{ resource_prefix }}-vpc" - - vpc_result.vpc.tags["Description"] == "Created by ansible-test" - - # ============================================================ - - name: Search for internet gateway by VPC - no matches - ec2_vpc_igw_info: - filters: - attachment.vpc-id: '{{ vpc_result.vpc.id }}' - register: igw_info - - - name: Assert success - assert: - that: - - igw_info is successful - - '"internet_gateways" in igw_info' - - (igw_info.internet_gateways | length) == 0 - - # ============================================================ - - name: create internet gateway (expected changed=true) - CHECK_MODE - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - tags: - tag_one: '{{ resource_prefix }} One' - "Tag Two": 'two {{ resource_prefix }}' - register: vpc_igw_create - check_mode: yes - - - name: assert creation would happen (expected changed=true) - CHECK_MODE - assert: - that: - - vpc_igw_create is changed - - - name: create internet gateway (expected changed=true) - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - tags: - tag_one: '{{ resource_prefix }} One' - "Tag Two": 'two {{ resource_prefix }}' - register: vpc_igw_create - - - name: assert creation happened (expected changed=true) - assert: - that: - - vpc_igw_create is changed - - 'vpc_igw_create.gateway_id.startswith("igw-")' - - 'vpc_igw_create.vpc_id == vpc_result.vpc.id' - - '"tags" in vpc_igw_create' - - vpc_igw_create.tags | length == 2 - - vpc_igw_create.tags["tag_one"] == '{{ resource_prefix }} One' - - vpc_igw_create.tags["Tag Two"] == 'two {{ resource_prefix }}' - - '"gateway_id" in vpc_igw_create' - - # ============================================================ - - name: Save IDs for later - set_fact: - igw_id: '{{ vpc_igw_create.gateway_id }}' - vpc_id: '{{ vpc_result.vpc.id }}' - - # ============================================================ - - name: Search for internet gateway by VPC - ec2_vpc_igw_info: - filters: - attachment.vpc-id: '{{ vpc_id }}' - register: igw_info - - - name: 'Check standard IGW details' - assert: - that: - - '"internet_gateways" in igw_info' - - igw_info.internet_gateways | length == 1 - - '"attachments" in current_igw' - - current_igw.attachments | length == 1 - - '"state" in current_igw.attachments[0]' - - current_igw.attachments[0].state == "available" - - '"vpc_id" in current_igw.attachments[0]' - - current_igw.attachments[0].vpc_id == vpc_id - - '"internet_gateway_id" in current_igw' - - current_igw.internet_gateway_id == igw_id - - '"tags" in current_igw' - - current_igw.tags | length == 2 - - '"key" in current_igw.tags[0]' - - '"value" in current_igw.tags[0]' - - '"key" in current_igw.tags[1]' - - '"value" in current_igw.tags[1]' - # Order isn't guaranteed in boto3 style, so just check the keys and - # values we expect are in there. - - current_igw.tags[0].key in ["tag_one", "Tag Two"] - - current_igw.tags[1].key in ["tag_one", "Tag Two"] - - current_igw.tags[0].value in [resource_prefix + " One", "two " + resource_prefix] - - current_igw.tags[1].value in [resource_prefix + " One", "two " + resource_prefix] - vars: - current_igw: '{{ igw_info.internet_gateways[0] }}' - - # ============================================================ - - name: Fetch IGW by ID - ec2_vpc_igw_info: - internet_gateway_ids: '{{ igw_id }}' - convert_tags: yes - register: igw_info - - - name: 'Check standard IGW details' - assert: - that: - - '"internet_gateways" in igw_info' - - igw_info.internet_gateways | length == 1 - - '"attachments" in current_igw' - - current_igw.attachments | length == 1 - - '"state" in current_igw.attachments[0]' - - current_igw.attachments[0].state == "available" - - '"vpc_id" in current_igw.attachments[0]' - - current_igw.attachments[0].vpc_id == vpc_id - - '"internet_gateway_id" in current_igw' - - current_igw.internet_gateway_id == igw_id - - '"tags" in current_igw' - - current_igw.tags | length == 2 - - '"tag_one" in current_igw.tags' - - '"Tag Two" in current_igw.tags' - - current_igw.tags["tag_one"] == '{{ resource_prefix }} One' - - current_igw.tags["Tag Two"] == 'two {{ resource_prefix }}' - vars: - current_igw: '{{ igw_info.internet_gateways[0] }}' - - # ============================================================ - - name: Fetch IGW by ID (list) - ec2_vpc_igw_info: - internet_gateway_ids: - - '{{ igw_id }}' - register: igw_info - - - name: 'Check standard IGW details' - assert: - that: - - '"internet_gateways" in igw_info' - - igw_info.internet_gateways | length == 1 - - '"attachments" in current_igw' - - current_igw.attachments | length == 1 - - '"state" in current_igw.attachments[0]' - - current_igw.attachments[0].state == "available" - - '"vpc_id" in current_igw.attachments[0]' - - current_igw.attachments[0].vpc_id == vpc_id - - '"internet_gateway_id" in current_igw' - - current_igw.internet_gateway_id == igw_id - - '"tags" in current_igw' - vars: - current_igw: '{{ igw_info.internet_gateways[0] }}' - - # ============================================================ - - name: attempt to recreate internet gateway on VPC (expected changed=false) - CHECK_MODE - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_igw_recreate - check_mode: yes - - - name: assert recreation would do nothing (expected changed=false) - CHECK_MODE - assert: - that: - - vpc_igw_recreate is not changed - - vpc_igw_recreate.gateway_id == igw_id - - vpc_igw_recreate.vpc_id == vpc_id - - '"tags" in vpc_igw_create' - - vpc_igw_create.tags | length == 2 - - vpc_igw_create.tags["tag_one"] == '{{ resource_prefix }} One' - - vpc_igw_create.tags["Tag Two"] == 'two {{ resource_prefix }}' - - - name: attempt to recreate internet gateway on VPC (expected changed=false) - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_igw_recreate - - - name: assert recreation did nothing (expected changed=false) - assert: - that: - - vpc_igw_recreate is not changed - - vpc_igw_recreate.gateway_id == igw_id - - vpc_igw_recreate.vpc_id == vpc_id - - '"tags" in vpc_igw_create' - - vpc_igw_create.tags | length == 2 - - vpc_igw_create.tags["tag_one"] == '{{ resource_prefix }} One' - - vpc_igw_create.tags["Tag Two"] == 'two {{ resource_prefix }}' - - # ============================================================ - - name: Update the tags (no change) - CHECK_MODE - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - tags: - tag_one: '{{ resource_prefix }} One' - "Tag Two": 'two {{ resource_prefix }}' - register: vpc_igw_recreate - check_mode: yes - - - name: assert tag update would do nothing (expected changed=false) - CHECK_MODE - assert: - that: - - vpc_igw_recreate is not changed - - vpc_igw_recreate.gateway_id == igw_id - - vpc_igw_recreate.vpc_id == vpc_id - - '"tags" in vpc_igw_recreate' - - vpc_igw_recreate.tags | length == 2 - - vpc_igw_recreate.tags["tag_one"] == '{{ resource_prefix }} One' - - vpc_igw_recreate.tags["Tag Two"] == 'two {{ resource_prefix }}' - - - name: Update the tags (no change) - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - tags: - tag_one: '{{ resource_prefix }} One' - "Tag Two": 'two {{ resource_prefix }}' - register: vpc_igw_recreate - - - name: assert tag update did nothing (expected changed=false) - assert: - that: - - vpc_igw_recreate is not changed - - vpc_igw_recreate.gateway_id == igw_id - - vpc_igw_recreate.vpc_id == vpc_id - - '"tags" in vpc_igw_recreate' - - vpc_igw_recreate.tags | length == 2 - - vpc_igw_recreate.tags["tag_one"] == '{{ resource_prefix }} One' - - vpc_igw_recreate.tags["Tag Two"] == 'two {{ resource_prefix }}' - - # ============================================================ - - name: Update the tags - remove and add - CHECK_MODE - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - tags: - tag_three: '{{ resource_prefix }} Three' - "Tag Two": 'two {{ resource_prefix }}' - register: vpc_igw_update - check_mode: yes - - - name: assert tag update would happen (expected changed=true) - CHECK_MODE - assert: - that: - - vpc_igw_update is changed - - vpc_igw_update.gateway_id == igw_id - - vpc_igw_update.vpc_id == vpc_id - - '"tags" in vpc_igw_update' - - vpc_igw_update.tags | length == 2 - - vpc_igw_update.tags["tag_three"] == '{{ resource_prefix }} Three' - - vpc_igw_update.tags["Tag Two"] == 'two {{ resource_prefix }}' - - - - name: Update the tags - remove and add - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - tags: - tag_three: '{{ resource_prefix }} Three' - "Tag Two": 'two {{ resource_prefix }}' - register: vpc_igw_update - - - name: assert tags are updated (expected changed=true) - assert: - that: - - vpc_igw_update is changed - - vpc_igw_update.gateway_id == igw_id - - vpc_igw_update.vpc_id == vpc_id - - '"tags" in vpc_igw_update' - - vpc_igw_update.tags | length == 2 - - vpc_igw_update.tags["tag_three"] == '{{ resource_prefix }} Three' - - vpc_igw_update.tags["Tag Two"] == 'two {{ resource_prefix }}' - - # ============================================================ - - name: Update the tags add without purge - CHECK_MODE - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - purge_tags: no - tags: - tag_one: '{{ resource_prefix }} One' - register: vpc_igw_update - check_mode: yes - - - name: assert tags would be added - CHECK_MODE - assert: - that: - - vpc_igw_update is changed - - vpc_igw_update.gateway_id == igw_id - - vpc_igw_update.vpc_id == vpc_id - - '"tags" in vpc_igw_update' - - vpc_igw_update.tags | length == 3 - - vpc_igw_update.tags["tag_one"] == '{{ resource_prefix }} One' - - vpc_igw_update.tags["tag_three"] == '{{ resource_prefix }} Three' - - vpc_igw_update.tags["Tag Two"] == 'two {{ resource_prefix }}' - - - name: Update the tags add without purge - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - purge_tags: no - tags: - tag_one: '{{ resource_prefix }} One' - register: vpc_igw_update - - - name: assert tags added - assert: - that: - - vpc_igw_update is changed - - vpc_igw_update.gateway_id == igw_id - - vpc_igw_update.vpc_id == vpc_id - - '"tags" in vpc_igw_update' - - vpc_igw_update.tags | length == 3 - - vpc_igw_update.tags["tag_one"] == '{{ resource_prefix }} One' - - vpc_igw_update.tags["tag_three"] == '{{ resource_prefix }} Three' - - vpc_igw_update.tags["Tag Two"] == 'two {{ resource_prefix }}' - - - # ============================================================ - - name: Update with CamelCase tags - CHECK_MODE - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - tags: - "lowercase spaced": 'hello cruel world ❤️' - "Title Case": 'Hello Cruel World ❤️' - CamelCase: 'SimpleCamelCase ❤️' - snake_case: 'simple_snake_case ❤️' - register: vpc_igw_update - check_mode: yes - - - name: assert tag update would happen (expected changed=true) - CHECK_MODE - assert: - that: - - vpc_igw_update is changed - - vpc_igw_update.gateway_id == igw_id - - vpc_igw_update.vpc_id == vpc_id - - '"tags" in vpc_igw_update' - - vpc_igw_update.tags | length == 4 - - vpc_igw_update.tags["lowercase spaced"] == 'hello cruel world ❤️' - - vpc_igw_update.tags["Title Case"] == 'Hello Cruel World ❤️' - - vpc_igw_update.tags["CamelCase"] == 'SimpleCamelCase ❤️' - - vpc_igw_update.tags["snake_case"] == 'simple_snake_case ❤️' - - - - name: Update the tags - remove and add - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - tags: - "lowercase spaced": 'hello cruel world ❤️' - "Title Case": 'Hello Cruel World ❤️' - CamelCase: 'SimpleCamelCase ❤️' - snake_case: 'simple_snake_case ❤️' - register: vpc_igw_update - - - name: assert tags are updated (expected changed=true) - assert: - that: - - vpc_igw_update is changed - - vpc_igw_update.gateway_id == igw_id - - vpc_igw_update.vpc_id == vpc_id - - '"tags" in vpc_igw_update' - - vpc_igw_update.tags | length == 4 - - vpc_igw_update.tags["lowercase spaced"] == 'hello cruel world ❤️' - - vpc_igw_update.tags["Title Case"] == 'Hello Cruel World ❤️' - - vpc_igw_update.tags["CamelCase"] == 'SimpleCamelCase ❤️' - - vpc_igw_update.tags["snake_case"] == 'simple_snake_case ❤️' - - # ============================================================ - - name: Gather information about a filtered list of Internet Gateways using tags - ec2_vpc_igw_info: - filters: - "tag:Title Case": 'Hello Cruel World ❤️' - register: igw_info - - - name: Assert success - assert: - that: - - igw_info is successful - - '"internet_gateways" in igw_info' - - igw_info.internet_gateways | selectattr("internet_gateway_id",'equalto',"{{ igw_id }}") - - - name: Gather information about a filtered list of Internet Gateways using tags - CHECK_MODE - ec2_vpc_igw_info: - filters: - "tag:Title Case": 'Hello Cruel World ❤️' - register: igw_info - check_mode: yes - - - name: Assert success - CHECK_MODE - assert: - that: - - igw_info is successful - - '"internet_gateways" in igw_info' - - igw_info.internet_gateways | selectattr("internet_gateway_id",'equalto',"{{ igw_id }}") - - # ============================================================ - - name: Gather information about a filtered list of Internet Gateways using tags (no match) - ec2_vpc_igw_info: - filters: - "tag:tag_one": '{{ resource_prefix }} One' - register: igw_info - - - name: Assert success - assert: - that: - - igw_info is successful - - '"internet_gateways" in igw_info' - - igw_info.internet_gateways | length == 0 - - - name: Gather information about a filtered list of Internet Gateways using tags (no match) - CHECK_MODE - ec2_vpc_igw_info: - filters: - "tag:tag_one": '{{ resource_prefix }} One' - register: igw_info - check_mode: yes - - - name: Assert success - CHECK_MODE - assert: - that: - - igw_info is successful - - '"internet_gateways" in igw_info' - - igw_info.internet_gateways | length == 0 - - # ============================================================ - - name: Remove all tags - CHECK_MODE - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - tags: {} - register: vpc_igw_update - check_mode: yes - - - name: assert tags would be removed - CHECK_MODE - assert: - that: - - vpc_igw_update is changed - - - name: Remove all tags - ec2_vpc_igw: - state: present - vpc_id: "{{ vpc_result.vpc.id }}" - tags: {} - register: vpc_igw_update - - - name: assert tags removed - assert: - that: - - vpc_igw_update is changed - - vpc_igw_update.gateway_id == igw_id - - vpc_igw_update.vpc_id == vpc_id - - '"tags" in vpc_igw_update' - - vpc_igw_update.tags | length == 0 - - # ============================================================ - - name: test state=absent (expected changed=true) - CHECK_MODE - ec2_vpc_igw: - state: absent - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_igw_delete - check_mode: yes - - - name: assert state=absent (expected changed=true) - CHECK_MODE - assert: - that: - - vpc_igw_delete is changed - - - name: test state=absent (expected changed=true) - ec2_vpc_igw: - state: absent - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_igw_delete - - - name: assert state=absent (expected changed=true) - assert: - that: - - vpc_igw_delete is changed - - # ============================================================ - - name: Fetch IGW by ID (list) - ec2_vpc_igw_info: - internet_gateway_ids: - - '{{ igw_id }}' - register: igw_info - ignore_errors: True - - - name: 'Check IGW does not exist' - assert: - that: - # Deliberate choice not to change bevahiour when searching by ID - - igw_info is failed - - # ============================================================ - - name: test state=absent when already deleted (expected changed=false) - CHECK_MODE - ec2_vpc_igw: - state: absent - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_igw_delete - check_mode: yes - - - name: assert state=absent (expected changed=false) - CHECK_MODE - assert: - that: - - vpc_igw_delete is not changed - - - name: test state=absent when already deleted (expected changed=false) - ec2_vpc_igw: - state: absent - vpc_id: "{{ vpc_result.vpc.id }}" - register: vpc_igw_delete - - - name: assert state=absent (expected changed=false) - assert: - that: - - vpc_igw_delete is not changed - - always: - # ============================================================ - - name: tidy up IGW - ec2_vpc_igw: - state: absent - vpc_id: "{{ vpc_result.vpc.id }}" - ignore_errors: true - - - name: tidy up VPC - ec2_vpc_net: - name: "{{ vpc_name }}" - state: absent - cidr_block: "{{ vpc_cidr }}" - ignore_errors: true From 9302b420e80e590885d2f0b7f4b7637089f0a15d Mon Sep 17 00:00:00 2001 From: Jill Rouleau Date: Tue, 27 Jul 2021 14:00:13 -0700 Subject: [PATCH 2/3] Update ignore files --- tests/sanity/ignore-2.9.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt index ba2989f08c6..16062bb5c52 100644 --- a/tests/sanity/ignore-2.9.txt +++ b/tests/sanity/ignore-2.9.txt @@ -15,7 +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_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 plugins/modules/ec2_vpc_route_table_info.py pylint:ansible-deprecated-no-version @@ -44,4 +43,4 @@ plugins/modules/rds.py validate-modules:invalid-documentation # Ansible 2.9 doc plugins/modules/rds_instance_info.py pylint:ansible-deprecated-no-version plugins/modules/rds_snapshot_info.py pylint:ansible-deprecated-no-version plugins/modules/redshift_info.py pylint:ansible-deprecated-no-version -plugins/modules/route53_info.py pylint:ansible-deprecated-no-version \ No newline at end of file +plugins/modules/route53_info.py pylint:ansible-deprecated-no-version From 6874c631f26e73f119cc67fbce6f9f65afb14c1f Mon Sep 17 00:00:00 2001 From: Jill Rouleau Date: Tue, 27 Jul 2021 14:06:26 -0700 Subject: [PATCH 3/3] Changelog and meta/runtime.yml for module removal --- changelogs/fragments/migrate_ec2_vpc_igw.yml | 10 ++++++++++ meta/runtime.yml | 14 +++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/migrate_ec2_vpc_igw.yml diff --git a/changelogs/fragments/migrate_ec2_vpc_igw.yml b/changelogs/fragments/migrate_ec2_vpc_igw.yml new file mode 100644 index 00000000000..6ab3da37409 --- /dev/null +++ b/changelogs/fragments/migrate_ec2_vpc_igw.yml @@ -0,0 +1,10 @@ +breaking_changes: +- ec2_vpc_igw_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_igw_info``. +- ec2_vpc_igw - 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_igw``. +- ec2_vpc_igw_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_igw_info``. diff --git a/meta/runtime.yml b/meta/runtime.yml index 0fbca024bee..7572647d422 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,4 +1,3 @@ ---- requires_ansible: '>=2.9.10' action_groups: aws: @@ -21,7 +20,6 @@ action_groups: - ec2_elb_facts - ec2_lc_facts - ec2_placement_group_facts - - ec2_vpc_igw_facts - ec2_vpc_nacl_facts - ec2_vpc_peering_facts - ec2_vpc_route_table_facts @@ -124,8 +122,6 @@ action_groups: - ec2_transit_gateway - ec2_transit_gateway_info - ec2_vpc_egress_igw - - ec2_vpc_igw - - ec2_vpc_igw_info - ec2_vpc_nacl - ec2_vpc_nacl_info - ec2_vpc_peer @@ -342,11 +338,11 @@ plugin_routing: ec2_vpc_endpoint_service_info: redirect: amazon.aws.ec2_vpc_endpoint_service_info ec2_vpc_igw_facts: - deprecation: - removal_date: 2021-12-01 - warning_text: >- - ec2_vpc_igw_facts was renamed in Ansible 2.9 to ec2_vpc_igw_info. - Please update your tasks. + redirect: amazon.aws.ec2_vpc_igw_facts + ec2_vpc_igw: + redirect: amazon.aws.ec2_vpc_igw + ec2_vpc_igw_info: + redirect: amazon.aws.ec2_vpc_igw_info ec2_vpc_nacl_facts: deprecation: removal_date: 2021-12-01