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

AWS EIP does not have attribute ID #5185

Closed
elliottsam opened this issue Feb 18, 2016 · 19 comments
Closed

AWS EIP does not have attribute ID #5185

elliottsam opened this issue Feb 18, 2016 · 19 comments

Comments

@elliottsam
Copy link

Hi,
When trying to associate an EIP with a AWS NAT gateway, I am seeing the following error.

02:02:03 Error applying plan:
02:02:03 
02:02:03 1 error(s) occurred:
02:02:03 
02:02:03 * Resource 'aws_eip.nat' does not have attribute 'id' for variable 'aws_eip.nat.id'

This error occurs randomly and works normally 75% of the time, the logs show that the EIP was created before the NAT gateway.

@brikis98
Copy link
Contributor

Same problem here. As an added complexity, I'm using the count attribute on my aws_eip:

resource "aws_eip" "nat" {
    count = "${var.num_nat_gateways}"
    vpc = true
    depends_on = ["aws_internet_gateway.main"]
}

resource "aws_nat_gateway" "nat" {
    count = "${var.num_nat_gateways}"
    allocation_id = "${element(aws_eip.nat.*.id, count.index)}"
    subnet_id = "${element(aws_subnet.public.*.id, count.index)}"
    depends_on = ["aws_internet_gateway.main"]
}

The error I get intermittently is:

Resource 'aws_eip.nat' does not have attribute 'id' for variable 'aws_eip.nat.*.id'

@brikis98
Copy link
Contributor

May be related to #4944. I'm trying the depends_on workaround now too.

@c4milo
Copy link
Contributor

c4milo commented Apr 22, 2016

Even using depends_on, I have experienced sometimes AWS just taking more time than usual to replicate changes made by Terraform, causing this sort of errors to show up once in a while. Waiting for a little while and re-running terraform apply has worked for me.

@skarungan
Copy link

Got the same issue, while using different state-files
terraform apply -state=dev.tfstate ---> Runs fine and succeeds
terraform apply -state=qa.tfstate ----> Throws the following error

Error applying plan:

1 error(s) occurred:

* Resource 'aws_eip.mgmt_nat_gw' does not have attribute 'id' for variable 'aws_eip.mgmt_nat_gw.id'

Re-running the command worked though

@NeckBeardPrince
Copy link

+1

@brikis98
Copy link
Contributor

Update: the depends_on workaround in #4944 does not work.

@cicdteam
Copy link

cicdteam commented Jul 1, 2016

Meet the same issue very often last days (especially when terraforming by CircleCI build process)

@carlossg
Copy link
Contributor

carlossg commented Jul 1, 2016

similar error is in #6991 with detailed logs

@hugoduncan
Copy link
Contributor

I'm seeing this too, when running terraform plan where the resources don't already exist. Adding a depends_on doesn't seem to help.

@hugoduncan
Copy link
Contributor

Running TF_VAR_availability_zones=us-east-1b,us-east-1e terraform plan on the below, when none of the resources exist on AWS, gives aws_nat_gateway.gateway #0: "allocation_id": required field is not set

variable aws_region {
  default = "us-east-1"
}

provider "aws" {
  region = "${var.aws_region}"
}

variable "availability_zones" {
  description = "Comma separated list of availability zones"
}

variable "cidrs" {
  default = {
    us-east-1b = "10.0.4.0/24"
    us-east-1d = "10.0.5.0/24"
    us-east-1e = "10.0.6.0/24"
  }
}

resource "aws_vpc" "vpc" {
  cidr_block = "10.0.0.0/16"
}

resource "aws_subnet" "public" {
  count = "${length(split(\",\", var.availability_zones))}"
  vpc_id = "${aws_vpc.vpc.id}"
  cidr_block = "${lookup(var.cidrs, element(split(\",\",var.availability_zones), count.index))}"
  availability_zone = "${element(split(\",\",var.availability_zones), count.index)}"
}

resource "aws_nat_gateway" "gateway" {
  count = "${length(split(\",\", var.availability_zones))}"
  subnet_id = "${element(aws_subnet.public.id, count.index)}"
}

@hugoduncan
Copy link
Contributor

It looks like using subnet_id = "${element(aws_subnet.public.*.id, count.index)}" fixes the issue.

@NeckBeardPrince
Copy link

Any news on getting this patched and fixed?

@pawelprazak
Copy link

Still an issue in Terraform v0.7.5

@bplunkert
Copy link

I am also experiencing this issue on v0.7.9.

@bodgit
Copy link
Contributor

bodgit commented Dec 22, 2016

I'm seeing something similar here when I try and use the (Allocation) ID of the EIP resource. I have the following:

resource "aws_eip" "haproxy" {
  vpc = true
}

The Allocation ID is needed by keepalived configuration so that whichever host in the cluster is the master can associate the EIP to itself (disassociating it first from a considered-dead peer if necessary) so I'm trying to pass the ID in a template_file resource:

data "template_file" "haproxy" {
  count = "${var.count}"
  template = "${file("template.tpl")}"
  vars {
    ...
    allocation_id = "${aws_eip.haproxy.id}"
    ...
  }
}

When I try and apply this I get the following error:

aws_eip.haproxy: Creating...
  allocation_id:     "" => "<computed>"
  association_id:    "" => "<computed>"
  domain:            "" => "<computed>"
  instance:          "" => "<computed>"
  network_interface: "" => "<computed>"
  private_ip:        "" => "<computed>"
  public_ip:         "" => "<computed>"
  vpc:               "" => "true"
...

* Resource 'aws_eip.haproxy' does not have attribute 'id' for variable 'aws_eip.haproxy.id'

Terraform has created the EIP resource but it didn't make it into the state file so if I re-apply I end up with multiple "orphaned" EIP resources in AWS. If I remove the dependency from the data template then everything works but I don't have the ID in the templates. If I use something else like the public_ip attribute then this works fine, it seems to be just the id attribute that breaks this.

I'm seeing this with 0.8.1.

@Ninir
Copy link
Contributor

Ninir commented Aug 28, 2017

Hey folks,

Since it seems to be an intermittent issue: Is anyone still having the issue?
Would like to close it in the AWS provider if it does not exist anymore! Thanks :)

@c4milo
Copy link
Contributor

c4milo commented Aug 28, 2017

@Ninir, nop, I would close it and open a new one if it comes up again.

@Ninir
Copy link
Contributor

Ninir commented Aug 28, 2017

Thanks for letting me know @c4milo, cheers!

@ghost
Copy link

ghost commented Apr 7, 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 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests