1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

ec2_vpc: Fix error when using InstanceId as a route gateway.

See https://github.com/ansible/ansible/issues/7368

Fixes #7368
This commit is contained in:
Yap Sok Ann 2014-05-30 11:52:13 +08:00 committed by James Cammarata
parent 9896898902
commit f80467e013

View file

@ -414,15 +414,17 @@ def create_vpc(module, vpc_conn):
try: try:
new_rt = vpc_conn.create_route_table(vpc.id) new_rt = vpc_conn.create_route_table(vpc.id)
for route in rt['routes']: for route in rt['routes']:
r_gateway = route['gw'] route_kwargs = {}
if r_gateway == 'igw': if route['gw'] == 'igw':
if not internet_gateway: if not internet_gateway:
module.fail_json( module.fail_json(
msg='You asked for an Internet Gateway ' \ msg='You asked for an Internet Gateway ' \
'(igw) route, but you have no Internet Gateway' '(igw) route, but you have no Internet Gateway'
) )
r_gateway = igw.id route_kwargs['gateway_id'] = igw.id
vpc_conn.create_route(new_rt.id, route['dest'], r_gateway) else:
route_kwargs['instance_id'] = route['gw']
vpc_conn.create_route(new_rt.id, route['dest'], **route_kwargs)
# Associate with subnets # Associate with subnets
for sn in rt['subnets']: for sn in rt['subnets']: