Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in aws_route_table when using network_interface_id/instance_id #4311

Closed
johnrengelman opened this issue Dec 14, 2015 · 16 comments
Closed

Comments

@johnrengelman
Copy link
Contributor

When setting a route entry in the aws_route_table resource, you are limited to using one of a variety of options, including network_interface_id or instance_id.

This works, however, when using one of these options, the state file stores values for both of them (it must resolve one from the other). and subsequent terraform plans show changes to be made.

@dbatwa
Copy link

dbatwa commented Dec 24, 2015

This is particularly problematic when using NAT instances.

@tkellen
Copy link

tkellen commented Jan 19, 2016

I'm seeing this as well, in terraform 0.6.9. Would ya'll like a repo with a reproduction of this?

@jen20
Copy link
Contributor

jen20 commented Jan 19, 2016

Hi @tkellen! Yes please, if you have a config which reproduces this it would be great if you could post it!

@tkellen
Copy link

tkellen commented Jan 19, 2016

Moment. I'll whip one up! You can see it during runs of http://github.com/tkellen/infrastructure but that's like the furthest thing from an isolated test case.

@tkellen
Copy link

tkellen commented Jan 19, 2016

Here ya go!

variable "aws_access_key" { }
variable "aws_secret_key" { }

provider "aws" {
  access_key = "${var.aws_access_key}"
  secret_key = "${var.aws_secret_key}"
  region = "us-east-1"
}

resource "aws_vpc" "test" {
  cidr_block = "10.10.0.0/16"
}

resource "aws_route_table" "test" {
  vpc_id = "${aws_vpc.test.id}"
}

resource "aws_subnet" "test" {
  vpc_id = "${aws_vpc.test.id}"
  cidr_block = "10.10.10.0/24"
  availability_zone = "us-east-1a"
}

resource "aws_route" "test" {
  route_table_id = "${aws_route_table.test.id}"
  destination_cidr_block = "0.0.0.0/0"
  instance_id = "${aws_instance.nat.id}"
}

resource "aws_instance" "nat" {
  ami = "ami-184dc970"
  instance_type = "t2.nano"
  subnet_id = "${aws_subnet.test.id}"
}

Thanks for all the great work ya'll!

@jen20
Copy link
Contributor

jen20 commented Jan 19, 2016

Thanks @tkellen - that clearly demonstrates the issue. We'll get working on a fix for this.

@tkellen
Copy link

tkellen commented Jan 19, 2016

Sweet! If I had more time I'd attempt a patch to fix this myself--seems like a good first PR. Looking forward to seeing what the resolution looks like.

@conorgil
Copy link

Just came to file the same issue. Glad to see it is on the radar. The output always shown in my terraform plan calls look like this:

~ module.vpc.aws_route.ngw.0
    gateway_id:     "" => "nat-123"
    nat_gateway_id: "nat-123" => ""

@BSick7
Copy link
Contributor

BSick7 commented Feb 25, 2016

Sorry guys. I created aws_route and made a mistake.
I submitted a PR to fix.

@tkellen
Copy link

tkellen commented Feb 26, 2016

No need to be sorry @BSick7 -- thank you for the addition of this functionality, and for the fix!

@diroussel
Copy link

FYI, the PR is #5321

@stack72
Copy link
Contributor

stack72 commented Mar 9, 2016

This has been closed in #5321 :) Thanks for the report @tkellen and thanks for the awesome work @BSick7

@stack72 stack72 closed this as completed Mar 9, 2016
@madAndroid
Copy link

Awesome :) been waiting on this one for some time now .. thanks!!

gozer added a commit to nubisproject/nubis-deploy that referenced this issue Mar 18, 2016
@gozer
Copy link

gozer commented Mar 18, 2016

Turns out this is also affecting aws_route's route {} blocks in the same way:

variable "aws_access_key" { }
variable "aws_secret_key" { }

provider "aws" {
  access_key = "${var.aws_access_key}"
  secret_key = "${var.aws_secret_key}"
  region = "us-east-1"
}

resource "aws_vpc" "test" {
  cidr_block = "10.10.0.0/16"
}

resource "aws_network_interface" "nat" {
  subnet_id = "${aws_subnet.test.id}"
  source_dest_check = false
  attachment {
      instance = "${aws_instance.nat.id}"
     device_index = 1
    }
}

resource "aws_route_table" "test" {
  vpc_id = "${aws_vpc.test.id}"

  route {
    cidr_block = "0.0.0.0/0"
    network_interface_id = "${aws_network_interface.nat.id}"
  }
}

resource "aws_subnet" "test" {
  vpc_id = "${aws_vpc.test.id}"
  cidr_block = "10.10.10.0/24"
  availability_zone = "us-east-1a"
}

resource "aws_instance" "nat" {
  ami = "ami-184dc970"
  instance_type = "t2.nano"
  subnet_id = "${aws_subnet.test.id}"
}

@stack72
Copy link
Contributor

stack72 commented Mar 18, 2016

Hi @gozer,

I am going to link your comment here to the latest open issue for this continual recreation issue:

#4097

Paul

@ghost
Copy link

ghost commented Apr 27, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants