{"action":"created","comment":{"url":"https://api.github.com/repos/hashicorp/terraform/pulls/comments/33314031","id":33314031,"diff_hunk":"@@ -0,0 +1,177 @@\n+package aws\n+\n+import (\n+\t\"fmt\"\n+\t\"log\"\n+\n+\t\"github.com/aws/aws-sdk-go/aws\"\n+\t\"github.com/aws/aws-sdk-go/service/ec2\"\n+\t\"github.com/hashicorp/terraform/helper/schema\"\n+)\n+\n+// AWS Route resource Schema delcaration\n+func resourceAwsRoute() *schema.Resource {\n+\treturn &schema.Resource{\n+\t\tCreate: resourceAwsRouteCreate,\n+\t\tRead:   resourceAwsRouteRead,\n+\t\tUpdate: resourceAwsRouteUpdate,\n+\t\tDelete: resourceAwsRouteDelete,\n+\n+\t\tSchema: map[string]*schema.Schema{\n+\t\t\t\"destination_cidr_block\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tRequired: true,\n+\t\t\t},\n+\n+\t\t\t\"destination_prefix_list_id\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tComputed: true,\n+\t\t\t},\n+\n+\t\t\t\"gateway_id\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tOptional: true,\n+\t\t\t},\n+\n+\t\t\t\"instance_id\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tOptional: true,\n+\t\t\t},\n+\n+\t\t\t\"instance_owner_id\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tComputed: true,\n+\t\t\t},\n+\n+\t\t\t\"network_interface_id\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tOptional: true,\n+\t\t\t},\n+\n+\t\t\t\"origin\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tComputed: true,\n+\t\t\t},\n+\n+\t\t\t\"state\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tComputed: true,\n+\t\t\t},\n+\n+\t\t\t\"route_table_id\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tOptional: true,\n+\t\t\t},\n+\n+\t\t\t\"vpc_peering_connection_id\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tOptional: true,\n+\t\t\t},\n+\t\t},\n+\t}\n+}\n+\n+func resourceAwsRouteCreate(d *schema.ResourceData, meta interface{}) error {\n+\tconn := meta.(*AWSClient).ec2conn\n+\n+\tif d.Get(\"route_table_id\") == \"\" {\n+\t\tfmt.Errorf(\"Error: no route table ID specified to add the route to.\" +\n+\t\t\t\"Please specify the ID of the routing table to add the route to.\")\n+\n+\t}\n+\n+\t// Create the route\n+\tcreateOpts := &ec2.CreateRouteInput{\n+\t\tDestinationCIDRBlock:   aws.String(d.Get(\"destination_cidr_block\").(string)),\n+\t\tGatewayID:              aws.String(d.Get(\"gateway_id\").(string)),\n+\t\tInstanceID:             aws.String(d.Get(\"instance_id\").(string)),\n+\t\tNetworkInterfaceID:     aws.String(d.Get(\"network_interface_id\").(string)),\n+\t\tRouteTableID:           aws.String(d.Get(\"route_table_id\").(string)),\n+\t\tVPCPeeringConnectionID: aws.String(d.Get(\"vpc_peering_connection_id\").(string)),\n+\t}\n+\tlog.Printf(\"[DEBUG] Route create config: %#v\", createOpts)\n+\n+\t_, err := conn.CreateRoute(createOpts)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"Error creating route: %s\", err)\n+\t}\n+\n+\treturn resourceAwsRouteRead(d, meta)\n+}\n+\n+func resourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error {\n+\tconn := meta.(*AWSClient).ec2conn\n+\troute, err := findResourceRoute(conn, d)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\td.Set(\"destination_prefix_list_id\", *route.DestinationPrefixListID)\n+\td.Set(\"gateway_id\", *route.DestinationPrefixListID)\n+\td.Set(\"instance_id\", *route.InstanceID)\n+\td.Set(\"instance_owner_id\", *route.InstanceOwnerID)\n+\td.Set(\"network_interface_id\", *route.NetworkInterfaceID)\n+\td.Set(\"origin\", *route.Origin)\n+\td.Set(\"state\", *route.State)\n+\td.Set(\"vpc_peering_connection_id\", *route.VPCPeeringConnectionID)\n+\n+\treturn nil\n+}\n+\n+func resourceAwsRouteUpdate(d *schema.ResourceData, meta interface{}) error {\n+\tconn := meta.(*AWSClient).ec2conn\n+\n+\treplaceOpts := &ec2.ReplaceRouteInput{\n+\t\tDestinationCIDRBlock:   aws.String(d.Get(\"destination_cidr_block\").(string)),\n+\t\tGatewayID:              aws.String(d.Get(\"gateway_id\").(string)),\n+\t\tInstanceID:             aws.String(d.Get(\"instance_id\").(string)),\n+\t\tNetworkInterfaceID:     aws.String(d.Get(\"network_interface_id\").(string)),\n+\t\tRouteTableID:           aws.String(d.Get(\"route_table_id\").(string)),\n+\t\tVPCPeeringConnectionID: aws.String(d.Get(\"vpc_peering_connection_id\").(string)),\n+\t}\n+\tlog.Printf(\"[DEBUG] Route replace config: %#v\", replaceOpts)\n+\n+\t_, err := conn.ReplaceRoute(replaceOpts)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\treturn nil\n+}\n+\n+func resourceAwsRouteDelete(d *schema.ResourceData, meta interface{}) error {\n+\tconn := meta.(*AWSClient).ec2conn\n+\tdeleteOpts := &ec2.DeleteRouteInput{\n+\t\tDestinationCIDRBlock: aws.String(d.Get(\"destination_cidr_block\").(string)),\n+\t\tRouteTableID:         aws.String(d.Get(\"route_table_id\").(string)),\n+\t}\n+\n+\t_, err := conn.DeleteRoute(deleteOpts)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\treturn nil\n+}\n+\n+// Helper: retrieve a route\n+func findResourceRoute(conn *ec2.EC2, d *schema.ResourceData) (*ec2.Route, error) {\n+\trouteTableId := d.Get(\"route_table_id\").(string)\n+\n+\tfindOpts := &ec2.DescribeRouteTablesInput{\n+\t\tRouteTableIDs: []*string{&routeTableId},\n+\t}\n+\n+\tresp, err := conn.DescribeRouteTables(findOpts)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tfor _, route := range (*resp.RouteTables[0]).Routes {","path":"builtin/providers/aws/resource_aws_route.go","position":170,"original_position":170,"commit_id":"d86f0193b6d7de326a061eb1d1fd9811cdc06107","original_commit_id":"d86f0193b6d7de326a061eb1d1fd9811cdc06107","user":{"login":"gkze","id":3131232,"avatar_url":"https://avatars.githubusercontent.com/u/3131232?v=3","gravatar_id":"","url":"https://api.github.com/users/gkze","html_url":"https://github.com/gkze","followers_url":"https://api.github.com/users/gkze/followers","following_url":"https://api.github.com/users/gkze/following{/other_user}","gists_url":"https://api.github.com/users/gkze/gists{/gist_id}","starred_url":"https://api.github.com/users/gkze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkze/subscriptions","organizations_url":"https://api.github.com/users/gkze/orgs","repos_url":"https://api.github.com/users/gkze/repos","events_url":"https://api.github.com/users/gkze/events{/privacy}","received_events_url":"https://api.github.com/users/gkze/received_events","type":"User","site_admin":false},"body":"@catsby I think so, because if I don't wrap the dereference in parentheses, I get this error on running `make`:\r\n```bash\r\nbuiltin/providers/aws/resource_aws_route.go:165: invalid indirect of resp.RouteTables[0].Routes (type []*ec2.Route)\r\n```","created_at":"2015-06-25T22:55:16Z","updated_at":"2015-06-25T22:55:16Z","html_url":"https://github.com/hashicorp/terraform/pull/2454#discussion_r33314031","pull_request_url":"https://api.github.com/repos/hashicorp/terraform/pulls/2454","_links":{"self":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/comments/33314031"},"html":{"href":"https://github.com/hashicorp/terraform/pull/2454#discussion_r33314031"},"pull_request":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/2454"}}},"pull_request":{"url":"https://api.github.com/repos/hashicorp/terraform/pulls/2454","id":38405273,"html_url":"https://github.com/hashicorp/terraform/pull/2454","diff_url":"https://github.com/hashicorp/terraform/pull/2454.diff","patch_url":"https://github.com/hashicorp/terraform/pull/2454.patch","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/2454","number":2454,"state":"open","locked":false,"title":"[WIP] provider/aws: add aws_route resource","user":{"login":"gkze","id":3131232,"avatar_url":"https://avatars.githubusercontent.com/u/3131232?v=3","gravatar_id":"","url":"https://api.github.com/users/gkze","html_url":"https://github.com/gkze","followers_url":"https://api.github.com/users/gkze/followers","following_url":"https://api.github.com/users/gkze/following{/other_user}","gists_url":"https://api.github.com/users/gkze/gists{/gist_id}","starred_url":"https://api.github.com/users/gkze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkze/subscriptions","organizations_url":"https://api.github.com/users/gkze/orgs","repos_url":"https://api.github.com/users/gkze/repos","events_url":"https://api.github.com/users/gkze/events{/privacy}","received_events_url":"https://api.github.com/users/gkze/received_events","type":"User","site_admin":false},"body":"Fixes #2388 \r\n\r\n**Status**\r\n- [ ] Acceptance tests\r\n- [ ] Creating route\r\n- [ ] Updating route\r\n- [ ] Deleting route\r\n\r\nP.S. I'm new to Go, so please criticize\r\n\r\ncc @phinze - still working my way through tests","created_at":"2015-06-24T03:48:31Z","updated_at":"2015-06-25T22:55:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b5e893eac0338bf7a9ead6d7ad0671518eeac874","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hashicorp/terraform/pulls/2454/commits","review_comments_url":"https://api.github.com/repos/hashicorp/terraform/pulls/2454/comments","review_comment_url":"https://api.github.com/repos/hashicorp/terraform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/2454/comments","statuses_url":"https://api.github.com/repos/hashicorp/terraform/statuses/d86f0193b6d7de326a061eb1d1fd9811cdc06107","head":{"label":"gkze:master","ref":"master","sha":"d86f0193b6d7de326a061eb1d1fd9811cdc06107","user":{"login":"gkze","id":3131232,"avatar_url":"https://avatars.githubusercontent.com/u/3131232?v=3","gravatar_id":"","url":"https://api.github.com/users/gkze","html_url":"https://github.com/gkze","followers_url":"https://api.github.com/users/gkze/followers","following_url":"https://api.github.com/users/gkze/following{/other_user}","gists_url":"https://api.github.com/users/gkze/gists{/gist_id}","starred_url":"https://api.github.com/users/gkze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkze/subscriptions","organizations_url":"https://api.github.com/users/gkze/orgs","repos_url":"https://api.github.com/users/gkze/repos","events_url":"https://api.github.com/users/gkze/events{/privacy}","received_events_url":"https://api.github.com/users/gkze/received_events","type":"User","site_admin":false},"repo":{"id":37679807,"name":"terraform","full_name":"gkze/terraform","owner":{"login":"gkze","id":3131232,"avatar_url":"https://avatars.githubusercontent.com/u/3131232?v=3","gravatar_id":"","url":"https://api.github.com/users/gkze","html_url":"https://github.com/gkze","followers_url":"https://api.github.com/users/gkze/followers","following_url":"https://api.github.com/users/gkze/following{/other_user}","gists_url":"https://api.github.com/users/gkze/gists{/gist_id}","starred_url":"https://api.github.com/users/gkze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkze/subscriptions","organizations_url":"https://api.github.com/users/gkze/orgs","repos_url":"https://api.github.com/users/gkze/repos","events_url":"https://api.github.com/users/gkze/events{/privacy}","received_events_url":"https://api.github.com/users/gkze/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gkze/terraform","description":"Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.","fork":true,"url":"https://api.github.com/repos/gkze/terraform","forks_url":"https://api.github.com/repos/gkze/terraform/forks","keys_url":"https://api.github.com/repos/gkze/terraform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gkze/terraform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gkze/terraform/teams","hooks_url":"https://api.github.com/repos/gkze/terraform/hooks","issue_events_url":"https://api.github.com/repos/gkze/terraform/issues/events{/number}","events_url":"https://api.github.com/repos/gkze/terraform/events","assignees_url":"https://api.github.com/repos/gkze/terraform/assignees{/user}","branches_url":"https://api.github.com/repos/gkze/terraform/branches{/branch}","tags_url":"https://api.github.com/repos/gkze/terraform/tags","blobs_url":"https://api.github.com/repos/gkze/terraform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gkze/terraform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gkze/terraform/git/refs{/sha}","trees_url":"https://api.github.com/repos/gkze/terraform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gkze/terraform/statuses/{sha}","languages_url":"https://api.github.com/repos/gkze/terraform/languages","stargazers_url":"https://api.github.com/repos/gkze/terraform/stargazers","contributors_url":"https://api.github.com/repos/gkze/terraform/contributors","subscribers_url":"https://api.github.com/repos/gkze/terraform/subscribers","subscription_url":"https://api.github.com/repos/gkze/terraform/subscription","commits_url":"https://api.github.com/repos/gkze/terraform/commits{/sha}","git_commits_url":"https://api.github.com/repos/gkze/terraform/git/commits{/sha}","comments_url":"https://api.github.com/repos/gkze/terraform/comments{/number}","issue_comment_url":"https://api.github.com/repos/gkze/terraform/issues/comments{/number}","contents_url":"https://api.github.com/repos/gkze/terraform/contents/{+path}","compare_url":"https://api.github.com/repos/gkze/terraform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gkze/terraform/merges","archive_url":"https://api.github.com/repos/gkze/terraform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gkze/terraform/downloads","issues_url":"https://api.github.com/repos/gkze/terraform/issues{/number}","pulls_url":"https://api.github.com/repos/gkze/terraform/pulls{/number}","milestones_url":"https://api.github.com/repos/gkze/terraform/milestones{/number}","notifications_url":"https://api.github.com/repos/gkze/terraform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gkze/terraform/labels{/name}","releases_url":"https://api.github.com/repos/gkze/terraform/releases{/id}","created_at":"2015-06-18T19:20:36Z","updated_at":"2015-06-18T19:20:40Z","pushed_at":"2015-06-24T03:44:24Z","git_url":"git://github.com/gkze/terraform.git","ssh_url":"git@github.com:gkze/terraform.git","clone_url":"https://github.com/gkze/terraform.git","svn_url":"https://github.com/gkze/terraform","homepage":"http://www.terraform.io","size":27660,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hashicorp:master","ref":"master","sha":"74386655a5b4bcc1123a00715637b302b119f824","user":{"login":"hashicorp","id":761456,"avatar_url":"https://avatars.githubusercontent.com/u/761456?v=3","gravatar_id":"","url":"https://api.github.com/users/hashicorp","html_url":"https://github.com/hashicorp","followers_url":"https://api.github.com/users/hashicorp/followers","following_url":"https://api.github.com/users/hashicorp/following{/other_user}","gists_url":"https://api.github.com/users/hashicorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hashicorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hashicorp/subscriptions","organizations_url":"https://api.github.com/users/hashicorp/orgs","repos_url":"https://api.github.com/users/hashicorp/repos","events_url":"https://api.github.com/users/hashicorp/events{/privacy}","received_events_url":"https://api.github.com/users/hashicorp/received_events","type":"Organization","site_admin":false},"repo":{"id":17728164,"name":"terraform","full_name":"hashicorp/terraform","owner":{"login":"hashicorp","id":761456,"avatar_url":"https://avatars.githubusercontent.com/u/761456?v=3","gravatar_id":"","url":"https://api.github.com/users/hashicorp","html_url":"https://github.com/hashicorp","followers_url":"https://api.github.com/users/hashicorp/followers","following_url":"https://api.github.com/users/hashicorp/following{/other_user}","gists_url":"https://api.github.com/users/hashicorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hashicorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hashicorp/subscriptions","organizations_url":"https://api.github.com/users/hashicorp/orgs","repos_url":"https://api.github.com/users/hashicorp/repos","events_url":"https://api.github.com/users/hashicorp/events{/privacy}","received_events_url":"https://api.github.com/users/hashicorp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hashicorp/terraform","description":"Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.","fork":false,"url":"https://api.github.com/repos/hashicorp/terraform","forks_url":"https://api.github.com/repos/hashicorp/terraform/forks","keys_url":"https://api.github.com/repos/hashicorp/terraform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hashicorp/terraform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hashicorp/terraform/teams","hooks_url":"https://api.github.com/repos/hashicorp/terraform/hooks","issue_events_url":"https://api.github.com/repos/hashicorp/terraform/issues/events{/number}","events_url":"https://api.github.com/repos/hashicorp/terraform/events","assignees_url":"https://api.github.com/repos/hashicorp/terraform/assignees{/user}","branches_url":"https://api.github.com/repos/hashicorp/terraform/branches{/branch}","tags_url":"https://api.github.com/repos/hashicorp/terraform/tags","blobs_url":"https://api.github.com/repos/hashicorp/terraform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hashicorp/terraform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hashicorp/terraform/git/refs{/sha}","trees_url":"https://api.github.com/repos/hashicorp/terraform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hashicorp/terraform/statuses/{sha}","languages_url":"https://api.github.com/repos/hashicorp/terraform/languages","stargazers_url":"https://api.github.com/repos/hashicorp/terraform/stargazers","contributors_url":"https://api.github.com/repos/hashicorp/terraform/contributors","subscribers_url":"https://api.github.com/repos/hashicorp/terraform/subscribers","subscription_url":"https://api.github.com/repos/hashicorp/terraform/subscription","commits_url":"https://api.github.com/repos/hashicorp/terraform/commits{/sha}","git_commits_url":"https://api.github.com/repos/hashicorp/terraform/git/commits{/sha}","comments_url":"https://api.github.com/repos/hashicorp/terraform/comments{/number}","issue_comment_url":"https://api.github.com/repos/hashicorp/terraform/issues/comments{/number}","contents_url":"https://api.github.com/repos/hashicorp/terraform/contents/{+path}","compare_url":"https://api.github.com/repos/hashicorp/terraform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hashicorp/terraform/merges","archive_url":"https://api.github.com/repos/hashicorp/terraform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hashicorp/terraform/downloads","issues_url":"https://api.github.com/repos/hashicorp/terraform/issues{/number}","pulls_url":"https://api.github.com/repos/hashicorp/terraform/pulls{/number}","milestones_url":"https://api.github.com/repos/hashicorp/terraform/milestones{/number}","notifications_url":"https://api.github.com/repos/hashicorp/terraform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hashicorp/terraform/labels{/name}","releases_url":"https://api.github.com/repos/hashicorp/terraform/releases{/id}","created_at":"2014-03-13T22:25:48Z","updated_at":"2015-06-25T18:56:45Z","pushed_at":"2015-06-25T22:41:51Z","git_url":"git://github.com/hashicorp/terraform.git","ssh_url":"git@github.com:hashicorp/terraform.git","clone_url":"https://github.com/hashicorp/terraform.git","svn_url":"https://github.com/hashicorp/terraform","homepage":"http://www.terraform.io","size":48085,"stargazers_count":2618,"watchers_count":2618,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":511,"mirror_url":null,"open_issues_count":376,"forks":511,"open_issues":376,"watchers":2618,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/2454"},"html":{"href":"https://github.com/hashicorp/terraform/pull/2454"},"issue":{"href":"https://api.github.com/repos/hashicorp/terraform/issues/2454"},"comments":{"href":"https://api.github.com/repos/hashicorp/terraform/issues/2454/comments"},"review_comments":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/2454/comments"},"review_comment":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/2454/commits"},"statuses":{"href":"https://api.github.com/repos/hashicorp/terraform/statuses/d86f0193b6d7de326a061eb1d1fd9811cdc06107"}}}}