Skip to content

Commit

Permalink
ec2_vpc_route_table: Add support to configure Transit Gateway routes…
Browse files Browse the repository at this point in the history
… in route table (ansible-collections#2291)

SUMMARY


Fixes ansible-collections#478
This PR updates the ec2_vpc_route_table "routes" parameter to support the transit gateway id.
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis
Reviewed-by: Bikouo Aubin
Reviewed-by: Mark Chappell
Reviewed-by: GomathiselviS
  • Loading branch information
GomathiselviS authored Sep 16, 2024
1 parent 55460c9 commit 14d447b
Show file tree
Hide file tree
Showing 4 changed files with 240 additions and 114 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/ec2_vpc_rote_table_transit_gateway.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- ec2_vpc_route_table - update the ec2_vpc_route_table routes parameter to support the transit gateway id (https://github.com/ansible-collections/amazon.aws/pull/2291).
13 changes: 11 additions & 2 deletions plugins/modules/ec2_vpc_route_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
description:
- List of routes in the route table.
- Routes are specified as dicts containing the keys V(dest) and one of V(gateway_id),
V(instance_id), V(network_interface_id), or V(vpc_peering_connection_id).
V(instance_id), V(network_interface_id), V(transit_gateway_id), or V(vpc_peering_connection_id).
- The value of V(dest) is used for the destination match. It may be a IPv4 CIDR block
or a IPv6 CIDR block.
- If V(gateway_id) is specified, you can refer to the VPC's IGW by using the value V(igw).
Expand Down Expand Up @@ -108,6 +108,8 @@
gateway_id: "{{ igw.gateway_id }}"
- dest: ::/0
gateway_id: "{{ igw.gateway_id }}"
- dest: 0.0.0.0/0
gateway_id: "{{ transit_gateway_id }}"
register: public_route_table
- name: Create VPC gateway
Expand Down Expand Up @@ -266,6 +268,12 @@
type: str
sample: local
version_added: 6.0.0
transit_gateway_id:
description: ID of the Transit gateway.
returned: when the route is via a Transit gateway
type: str
sample: tgw-123456789012
version_added: 8.3.0
origin:
description: mechanism through which the route is in the table.
returned: always
Expand Down Expand Up @@ -700,6 +708,8 @@ def create_route_spec(connection, module, vpc_id):
rename_key(route_spec, "gateway_id", "nat_gateway_id")
if route_spec.get("gateway_id") and route_spec["gateway_id"].startswith("cagw-"):
rename_key(route_spec, "gateway_id", "carrier_gateway_id")
if route_spec.get("gateway_id") and route_spec["gateway_id"].startswith("tgw-"):
rename_key(route_spec, "gateway_id", "transit_gateway_id")

return snake_dict_to_camel_dict(routes, capitalize_first=True)

Expand Down Expand Up @@ -776,7 +786,6 @@ def ensure_route_table_present(connection, module: AnsibleAWSModule) -> Dict[str
)
else:
gateway_changed = False

changed = changed or gateway_changed

if changed:
Expand Down
6 changes: 6 additions & 0 deletions plugins/modules/ec2_vpc_route_table_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@
returned: when the route is via a NAT gateway.
type: str
sample: local
transit_gateway_id:
description: ID of the Transit gateway.
returned: when the route is via a Transit gateway.
type: str
sample: tgw-123456789012
version_added: 8.3.0
origin:
description: mechanism through which the route is in the table.
returned: always
Expand Down
Loading

0 comments on commit 14d447b

Please sign in to comment.