From e595c8453940ad01162f38baf5a97ed45cfb6239 Mon Sep 17 00:00:00 2001 From: Damien Levac Date: Sun, 7 Mar 2021 10:22:58 -0500 Subject: [PATCH] Added support for 'vpc_endpoint_type'. (#460) * Added support for 'vpc_endpoint_type'. * Integration test for the 'vpc_endpoint_type' feature. * Added choices in documentation. * Added changelog. This commit was initially merged in https://github.com/ansible-collections/community.aws See: https://github.com/ansible-collections/community.aws/commit/4da568ad75b521272918295057ffeef4b2ea94a0 --- plugins/modules/ec2_vpc_endpoint.py | 11 +++++++++- .../targets/ec2_vpc_endpoint/tasks/main.yml | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/plugins/modules/ec2_vpc_endpoint.py b/plugins/modules/ec2_vpc_endpoint.py index 28d0fda0eba..d7d10769f06 100644 --- a/plugins/modules/ec2_vpc_endpoint.py +++ b/plugins/modules/ec2_vpc_endpoint.py @@ -21,6 +21,13 @@ - 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 service: description: - An AWS supported vpc endpoint service. Use the M(community.aws.ec2_vpc_endpoint_info) @@ -56,7 +63,7 @@ - absent to remove resource required: false default: present - choices: [ "present", "absent"] + choices: [ "present", "absent" ] type: str wait: description: @@ -251,6 +258,7 @@ def create_vpc_endpoint(client, module): 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') params['DryRun'] = module.check_mode @@ -334,6 +342,7 @@ def setup_removal(client, module): 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']), diff --git a/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml b/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml index d06ac92fa01..a8fdbec889d 100644 --- a/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_endpoint/tasks/main.yml @@ -353,6 +353,26 @@ 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