From f80467e0138a1a40becc40a12e01b398b058fbdf Mon Sep 17 00:00:00 2001 From: Yap Sok Ann Date: Fri, 30 May 2014 11:52:13 +0800 Subject: [PATCH] ec2_vpc: Fix error when using InstanceId as a route gateway. See https://github.com/ansible/ansible/issues/7368 Fixes #7368 --- library/cloud/ec2_vpc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/cloud/ec2_vpc b/library/cloud/ec2_vpc index 5d8d696647..5383f3892c 100644 --- a/library/cloud/ec2_vpc +++ b/library/cloud/ec2_vpc @@ -414,15 +414,17 @@ def create_vpc(module, vpc_conn): try: new_rt = vpc_conn.create_route_table(vpc.id) for route in rt['routes']: - r_gateway = route['gw'] - if r_gateway == 'igw': + route_kwargs = {} + if route['gw'] == 'igw': if not internet_gateway: module.fail_json( msg='You asked for an Internet Gateway ' \ '(igw) route, but you have no Internet Gateway' ) - r_gateway = igw.id - vpc_conn.create_route(new_rt.id, route['dest'], r_gateway) + route_kwargs['gateway_id'] = igw.id + else: + route_kwargs['instance_id'] = route['gw'] + vpc_conn.create_route(new_rt.id, route['dest'], **route_kwargs) # Associate with subnets for sn in rt['subnets']: