{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/6551","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/6551/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/6551/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/6551/events","html_url":"https://github.com/hashicorp/terraform/issues/6551","id":153749764,"number":6551,"title":"aws_route_table: Inconsistency when using gateway_id / nat_gateway_id","user":{"login":"dcarley","id":260438,"avatar_url":"https://avatars.githubusercontent.com/u/260438?v=3","gravatar_id":"","url":"https://api.github.com/users/dcarley","html_url":"https://github.com/dcarley","followers_url":"https://api.github.com/users/dcarley/followers","following_url":"https://api.github.com/users/dcarley/following{/other_user}","gists_url":"https://api.github.com/users/dcarley/gists{/gist_id}","starred_url":"https://api.github.com/users/dcarley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcarley/subscriptions","organizations_url":"https://api.github.com/users/dcarley/orgs","repos_url":"https://api.github.com/users/dcarley/repos","events_url":"https://api.github.com/users/dcarley/events{/privacy}","received_events_url":"https://api.github.com/users/dcarley/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hashicorp/terraform/labels/bug","name":"bug","color":"f7c6c7"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/provider/aws","name":"provider/aws","color":"bfdadc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-09T10:46:23Z","updated_at":"2016-05-31T10:40:09Z","closed_at":null,"body":"### Terraform Version\r\n\r\n```\r\n➜  ~ terraform -v\r\nTerraform v0.6.15\r\n```\r\n\r\n### Affected Resource(s)\r\n\r\n- aws_route_table\r\n\r\n### Terraform Configuration Files\r\n\r\nAn `aws_route_table` resource that incorrectly refers to an `aws_nat_gateway` using `gateway_id` instead of `nat_gateway_id`:\r\n\r\n```hcl\r\nprovider \"aws\" {\r\n  region = \"eu-west-1\"\r\n}\r\n\r\nresource \"aws_vpc\" \"test\" {\r\n  cidr_block = \"10.0.0.0/16\"\r\n}\r\n\r\nresource \"aws_eip\" \"test\" {\r\n  vpc = true\r\n}\r\n\r\nresource \"aws_subnet\" \"test\" {\r\n  vpc_id                  = \"${aws_vpc.test.id}\"\r\n  cidr_block              = \"${aws_vpc.test.cidr_block}\"\r\n  map_public_ip_on_launch = false\r\n}\r\n\r\nresource \"aws_internet_gateway\" \"test\" {\r\n  vpc_id = \"${aws_vpc.test.id}\"\r\n}\r\n\r\nresource \"aws_nat_gateway\" \"test\" {\r\n  allocation_id = \"${aws_eip.test.id}\"\r\n  subnet_id     = \"${aws_subnet.test.id}\"\r\n}\r\n\r\nresource \"aws_route_table\" \"test\" {\r\n  vpc_id = \"${aws_vpc.test.id}\"\r\n\r\n  route {\r\n    cidr_block = \"0.0.0.0/0\"\r\n    gateway_id = \"${aws_nat_gateway.test.id}\"\r\n  }\r\n}\r\n```\r\n\r\n### Expected Behavior\r\n\r\nWe could make it more user friendly in the face of incorrect configuration by doing one of either:\r\n\r\n- automatically converting the `gateway_id`/`nat_gateway_id` arguments during create or read based on the prefix of the ID, so that the resource isn't modified on subsequent `apply` runs\r\n- raising an error if an ID with an incompatible prefix is passed to `gateway_id`/`nat_gateway_id`\r\n- document the behaviour in the argument reference\r\n\r\nI'm happy to raise a pull request and acceptance test if we can decide on the correct solution.\r\n\r\n### Actual Behavior\r\n\r\nThe `aws_route_table` resource is modified on every `apply` because the AWS API automatically converts our incorrect `gateway_id` to `nat_gateway_id`:\r\n```\r\naws_route_table.test: Modifying...\r\n  route.3342964847.cidr_block:                \"\" => \"0.0.0.0/0\"\r\n  route.3342964847.gateway_id:                \"\" => \"nat-058b4dd1636a09817\"\r\n  route.3342964847.instance_id:               \"\" => \"\"\r\n  route.3342964847.nat_gateway_id:            \"\" => \"\"\r\n  route.3342964847.network_interface_id:      \"\" => \"\"\r\n  route.3342964847.vpc_peering_connection_id: \"\" => \"\"\r\n  route.3629674017.cidr_block:                \"0.0.0.0/0\" => \"\"\r\n  route.3629674017.gateway_id:                \"\" => \"\"\r\n  route.3629674017.instance_id:               \"\" => \"\"\r\n  route.3629674017.nat_gateway_id:            \"nat-058b4dd1636a09817\" => \"\"\r\n  route.3629674017.network_interface_id:      \"\" => \"\"\r\n  route.3629674017.vpc_peering_connection_id: \"\" => \"\"\r\naws_route_table.test: Modifications complete\r\n```\r\n\r\n### Steps to Reproduce\r\n\r\n1. Take the example configuration from above\r\n1. Run `terraform apply` once to create the resources\r\n1. Run` terraform apply` again to observe the resource being modified"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/222653076","html_url":"https://github.com/hashicorp/terraform/issues/6551#issuecomment-222653076","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/6551","id":222653076,"user":{"login":"hansnqyr","id":1787011,"avatar_url":"https://avatars.githubusercontent.com/u/1787011?v=3","gravatar_id":"","url":"https://api.github.com/users/hansnqyr","html_url":"https://github.com/hansnqyr","followers_url":"https://api.github.com/users/hansnqyr/followers","following_url":"https://api.github.com/users/hansnqyr/following{/other_user}","gists_url":"https://api.github.com/users/hansnqyr/gists{/gist_id}","starred_url":"https://api.github.com/users/hansnqyr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hansnqyr/subscriptions","organizations_url":"https://api.github.com/users/hansnqyr/orgs","repos_url":"https://api.github.com/users/hansnqyr/repos","events_url":"https://api.github.com/users/hansnqyr/events{/privacy}","received_events_url":"https://api.github.com/users/hansnqyr/received_events","type":"User","site_admin":false},"created_at":"2016-05-31T10:40:09Z","updated_at":"2016-05-31T10:40:09Z","body":"Agree that we probably shouldn't auto-assign, but maybe we could throw a warning or error when using a gateway_id starting \"nat-\" ?"}}
{"actor":{"display_login":"hansnqyr"}}