{"action":"created","issue":{"url":"https://api.github.com/repos/romanrev/ansible/issues/1","labels_url":"https://api.github.com/repos/romanrev/ansible/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/romanrev/ansible/issues/1/comments","events_url":"https://api.github.com/repos/romanrev/ansible/issues/1/events","html_url":"https://github.com/romanrev/ansible/pull/1","id":33301976,"number":1,"title":"Allow the use of an instance id in the route creation in ec2_vpc (for NAT private networks)","user":{"login":"romanrev","id":2794589,"avatar_url":"https://avatars.githubusercontent.com/u/2794589?v=3","gravatar_id":"","url":"https://api.github.com/users/romanrev","html_url":"https://github.com/romanrev","followers_url":"https://api.github.com/users/romanrev/followers","following_url":"https://api.github.com/users/romanrev/following{/other_user}","gists_url":"https://api.github.com/users/romanrev/gists{/gist_id}","starred_url":"https://api.github.com/users/romanrev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romanrev/subscriptions","organizations_url":"https://api.github.com/users/romanrev/orgs","repos_url":"https://api.github.com/users/romanrev/repos","events_url":"https://api.github.com/users/romanrev/events{/privacy}","received_events_url":"https://api.github.com/users/romanrev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2014-05-12T12:09:51Z","updated_at":"2015-03-02T22:21:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/romanrev/ansible/pulls/1","html_url":"https://github.com/romanrev/ansible/pull/1","diff_url":"https://github.com/romanrev/ansible/pull/1.diff","patch_url":"https://github.com/romanrev/ansible/pull/1.patch"},"body":"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.\r\n\r\nOtherwise upon trying to register a route with an existing (NAT) instance ID instead of the gateway ID one gets an error like follows:\r\n\r\n    failed: [127.0.0.1] => {\"failed\": true, \"item\": \"\"}\r\n    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\r\n    <?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n    <Response><Errors><Error><Code>InvalidGatewayID.NotFound</Code <Message>The gateway ID 'i-09d47501' does not exist</Message></Error></Errors><RequestID>fa95104e-37ab-44ee-b8fd-2c5033179585</RequestID></Response>"},"comment":{"url":"https://api.github.com/repos/romanrev/ansible/issues/comments/76839468","html_url":"https://github.com/romanrev/ansible/pull/1#issuecomment-76839468","issue_url":"https://api.github.com/repos/romanrev/ansible/issues/1","id":76839468,"user":{"login":"romanrev","id":2794589,"avatar_url":"https://avatars.githubusercontent.com/u/2794589?v=3","gravatar_id":"","url":"https://api.github.com/users/romanrev","html_url":"https://github.com/romanrev","followers_url":"https://api.github.com/users/romanrev/followers","following_url":"https://api.github.com/users/romanrev/following{/other_user}","gists_url":"https://api.github.com/users/romanrev/gists{/gist_id}","starred_url":"https://api.github.com/users/romanrev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romanrev/subscriptions","organizations_url":"https://api.github.com/users/romanrev/orgs","repos_url":"https://api.github.com/users/romanrev/repos","events_url":"https://api.github.com/users/romanrev/events{/privacy}","received_events_url":"https://api.github.com/users/romanrev/received_events","type":"User","site_admin":false},"created_at":"2015-03-02T22:21:36Z","updated_at":"2015-03-02T22:21:36Z","body":"Hi @arbabnazar. Please refer to the following [gist](https://gist.github.com/romanrev/9825c1831ca56038cba0) - an excerpt from my VPC setup playbook. The sequence of all required actions is marked in the [nat_setup.yml](https://gist.github.com/romanrev/9825c1831ca56038cba0#file-nat_setup-yml) by comments STEP 1-4, everything else in that playbook is just for reference so that all the used data structures are clear. I have also provided the templates and extracts from [group_vars/all](https://gist.github.com/romanrev/9825c1831ca56038cba0#file-group_vars_all) file for the same purpose. I hope you get the idea, if not - let me know and I can explain it further.\r\n\r\nIn a nutshell, all I do is:\r\n- (STEP 2-3). I merge the existing routing tables defined by `vpc_env.route_tables` in [group_vars/all](https://gist.github.com/romanrev/9825c1831ca56038cba0#file-group_vars_all) file with the ones constructed in [nat_routes.json.j2](https://gist.github.com/romanrev/9825c1831ca56038cba0#file-nat_routes-json-j2) Jinja template for the private subnets which need to be routed through the NAT instances\r\n- (STEP 4) call `ec2_vpc` module once again with the updated routing table constructed in the previous steps\r\n\r\nThe NAT instances also run a `nat_monitor.sh` script that allows them to take over the routes in case one of them stops responding - but that is only required in case of a redundant NAT setup, where two NATs are running in separate availability zones. In case of a single NAT, there would not be any need in that, and the `user_data` parameter in STEP 1 could be obviously dropped. "}}