From 7960220f89c17dadc0361937d24c7b4399736d52 Mon Sep 17 00:00:00 2001 From: Roman Revyakin Date: Mon, 12 May 2014 22:06:37 +1000 Subject: [PATCH] According to [boto.vpc.VPCCOnnection.create_route](http://bit.ly/1sku9W6) there is a need to use named parameters in the method call to differentiate between a gateway ID and an instance ID when trying to create a route Otherwise upon trying to register a route with an existing instance ID instead of the gateway ID one gets an error like follows: failed: [127.0.0.1] => {"failed": true, "item": ""} msg: Unable to create and associate route table {u'routes': [{u'dest': u'0.0.0.0/0', u'gw': u'i-09d47501'}], u'subnets': [u'10.1.10.0/24', u'10.1.12.0/24', u'10.1.20.0/24']}, error: EC2ResponseError: 400 Bad Request InvalidGatewayID.NotFoundThe gateway ID 'i-09d47501' does not existfa95104e-37ab-44ee-b8fd-2c5033179585 --- library/cloud/ec2_vpc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/cloud/ec2_vpc b/library/cloud/ec2_vpc index 683dd20d46137d..2d6b719fe93298 100644 --- a/library/cloud/ec2_vpc +++ b/library/cloud/ec2_vpc @@ -422,7 +422,10 @@ def create_vpc(module, vpc_conn): '(igw) route, but you have no Internet Gateway' ) r_gateway = igw.id - vpc_conn.create_route(new_rt.id, route['dest'], r_gateway) + if r_gateway[:3] == 'igw': + vpc_conn.create_route(new_rt.id, route['dest'], gateway_id=r_gateway) + else: + vpc_conn.create_route(new_rt.id, route['dest'], instance_id=r_gateway) # Associate with subnets for sn in rt['subnets']: