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] NAT Gateway diff error #4424

Closed
pporada-gl opened this issue Dec 22, 2015 · 4 comments
Closed

[AWS] NAT Gateway diff error #4424

pporada-gl opened this issue Dec 22, 2015 · 4 comments

Comments

@pporada-gl
Copy link

I built terraform from the develop branch and have encountered the following error.

Terraform version: 0.6.9 dev 757a42704e0fd550ecf2d5e84d076517bf85e339
* aws_nat_gateway.gateway.0: diffs didn't match during apply. This is a bug with Terraform and should be reported.

My environment has 3 availability zones and only 2 NAT gateways are being built. Every subsequent apply also fails to build the missing NAT gateway.

Here is my file structure

.
├── modules/
│   └── aws/
│       ├── data/
│       │   ├── data.tf
│       │   └── elasticache/
│       │       └── elasticache.tf
│       ├── dns/
│       │   └── dns.tf
│       ├── network/
│       │   ├── bastion/
│       │   │   └── bastion.tf
│       │   ├── nat/
│       │   │   └── nat.tf
│       │   ├── network.tf
│       │   ├── private_network/
│       │   │   └── private_network.tf
│       │   ├── public_network/
│       │   │   └── public_network.tf
│       │   └── vpc/
│               └── vpc.tf
└── providers/
    └── aws/
        ├── Makefile
        ├── README.md
        ├── environments/
        │   └── staging/
        │       └── staging.tfvars
        ├── main.tf
        └── terraform.tfstate.backup

nat.tf

variable "public_subnets" { }
variable "subnet_ids" { }

resource "aws_eip" "nat_gateway" {
    count   = "${length(split(",", var.public_subnets))}"
    vpc     = true
}

resource "aws_nat_gateway" "gateway" {
    count         = "${length(split(",", var.public_subnets))}"
    subnet_id     = "${element(split(",", var.subnet_ids), count.index)}"
    allocation_id = "${element(aws_eip.nat_gateway.*.id, count.index)}"
}

Attached is a debug log and screenshot of the aws console. Let me know what else you need from me.
tf.log.zip
screen shot 2015-12-22 at 3 25 42 pm

@pporada-gl
Copy link
Author

In my nat.tf, if I try to use subnet_ids for interpolation instead of public_subnets, I receive this error which seems identical to #3888

Errors:

  * strconv.ParseInt: parsing "${length(split(\",\", var.subnet_ids))}": invalid syntax
variable "public_subnets" { }
variable "subnet_ids" { }

resource "aws_eip" "nat_gateway" {
    count   = "${length(split(",", var.subnet_ids))}"
    vpc     = true
}

resource "aws_nat_gateway" "gateway" {
    count         = "${length(split(",", var.subnet_ids))}"
    subnet_id     = "${element(split(",", var.subnet_ids), count.index)}"
    allocation_id = "${element(aws_eip.nat_gateway.*.id, count.index)}"
}

@radeksimko
Copy link
Member

Cutting out the interesting part of the log:

2015/12/22 15:23:37 [ERROR] aws_nat_gateway.gateway.0: diffs didn't match
2015/12/22 15:23:37 [ERROR] aws_nat_gateway.gateway.0: reason: attribute mismatch: allocation_id
2015/12/22 15:23:37 [ERROR] aws_nat_gateway.gateway.0: diff one: *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff{"private_ip":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "public_ip":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "allocation_id":*terraform.ResourceAttrDiff{Old:"", New:"${element(split(\",\", aws_eip.nat_gateway.*.id), count.index)}", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "subnet_id":*terraform.ResourceAttrDiff{Old:"", New:"${element(split(\",\", var.subnet_ids), count.index)}", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "network_interface_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}}, Destroy:false, DestroyTainted:false}
2015/12/22 15:23:37 [ERROR] aws_nat_gateway.gateway.0: diff two: *terraform.InstanceDiff{Attributes:map[string]*terraform.ResourceAttrDiff{"subnet_id":*terraform.ResourceAttrDiff{Old:"", New:"subnet-683cd730", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Type:0x0}, "network_interface_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "private_ip":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}, "public_ip":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Type:0x0}}, Destroy:false, DestroyTainted:false}

which makes me think this is very likely related to #3888 (i.e. you're probably right)

@pporada-gl pporada-gl changed the title NAT Gateway diff error [AWS] NAT Gateway diff error Dec 23, 2015
@mitchellh
Copy link
Contributor

Yes, this is a manifestation of #3888, centralizing there

@ghost
Copy link

ghost commented Apr 21, 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 21, 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

3 participants