mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
* [cloud] ec2_vpc_route_table: ignore routes without DestinationCidrBlock Add module warnings rather than silently skipping * Permit warnings for routes tables containing vpc endpoints to be turned off * Add tests to ensure a VPC endpoint associated with a route table does not result in a traceback
This commit is contained in:
parent
f1899f784b
commit
da3f7a8db1
2 changed files with 62 additions and 3 deletions
|
@ -545,10 +545,55 @@
|
|||
- recreate_private_table.changed
|
||||
- recreate_private_table.route_table.id != create_public_table.route_table.id
|
||||
|
||||
- name: create a VPC endpoint to test ec2_vpc_route_table ignores it
|
||||
ec2_vpc_endpoint:
|
||||
state: present
|
||||
vpc_id: "{{ vpc.vpc.id }}"
|
||||
service: "com.amazonaws.{{ aws_region }}.s3"
|
||||
route_table_ids:
|
||||
- "{{ recreate_private_table.route_table.route_table_id }}"
|
||||
<<: *aws_connection_info
|
||||
register: vpc_endpoint
|
||||
|
||||
- name: purge routes
|
||||
ec2_vpc_route_table:
|
||||
vpc_id: "{{ vpc.vpc.id }}"
|
||||
tags:
|
||||
Public: "false"
|
||||
Name: "Private route table"
|
||||
routes:
|
||||
- nat_gateway_id: "{{ nat_gateway.nat_gateway_id }}"
|
||||
dest: 0.0.0.0/0
|
||||
subnets: "{{ vpc_subnets|json_query('subnets[?tags.Public == `False`].id') }}"
|
||||
purge_routes: true
|
||||
<<: *aws_connection_info
|
||||
register: result
|
||||
|
||||
- name: Get endpoint facts to verify that it wasn't purged from the route table
|
||||
ec2_vpc_endpoint_facts:
|
||||
query: endpoints
|
||||
vpc_endpoint_ids:
|
||||
- "{{ vpc_endpoint.result.vpc_endpoint_id }}"
|
||||
<<: *aws_connection_info
|
||||
register: endpoint_details
|
||||
|
||||
- name: assert the route table is associated with the VPC endpoint
|
||||
assert:
|
||||
that:
|
||||
- endpoint_details.vpc_endpoints[0].route_table_ids[0] == recreate_private_table.route_table.route_table_id
|
||||
|
||||
always:
|
||||
#############################################################################
|
||||
# TEAR DOWN STARTS HERE
|
||||
#############################################################################
|
||||
- name: remove the VPC endpoint
|
||||
ec2_vpc_endpoint:
|
||||
state: absent
|
||||
vpc_endpoint_id: "{{ vpc_endpoint.result.vpc_endpoint_id }}"
|
||||
<<: *aws_connection_info
|
||||
when: vpc_endpoint is defined
|
||||
ignore_errors: yes
|
||||
|
||||
- name: destroy route tables
|
||||
ec2_vpc_route_table:
|
||||
route_table_id: "{{ item.route_table.id }}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue