Open Ruwan-Ranganath opened 6 years ago
Hi, Assume I don't want to have any code level change in my terraform script ? and just doing terraform init will work ?
I managed to run this once but again receiving same kind of error .
* module.nat.google_compute_route.nat-gateway: element: element() may not be used with an empty list in:
${element(split("/", element(module.nat-gateway.instances[0], 0)), 10)}
* module.nat.output.instance: element: element() may not be used with an empty list in:
${element(module.nat-gateway.instances[0], 0)}
Hi, I had the same problem. To solve that, just change the name of your module. Your module name must be different of the name "nat-gateway" already use inside module terraform-google-nat-gateway.
After an error on the first run, the module now does not work with the above error
* module.nat.google_compute_route.nat-gateway: element: element() may not be used with an empty list in:
${element(split("/", element(module.nat-gateway.instances[0], 0)), 10)}
@mafrosis, can you post a snippet of your code and your terraform and provider versions?
Terraform version 11.7, and provider version 1.16. Nothing special happening with our use of the module - the code is as you would expect:
resource "google_compute_subnetwork" "nat_subnet" {
name = "nat-subnet"
ip_cidr_range = "10.255.255.0/24"
project = "${google_project.host_project.project_id}"
region = "${var.region}"
network = "${google_compute_network.shared_network.self_link}"
}
module "nat" {
source = "GoogleCloudPlatform/nat-gateway/google"
region = "${var.region}"
network = "${var.project_id}-vpc"
subnetwork = "${google_compute_subnetwork.nat_subnet.name}"
project = "${google_project.host_project.project_id}"
}
AFAICT the issue stemmed from a timeout when the MIG was creating, which left the terraform in an unrecoverable state with the error I pasted above.
I recovered with some manual intervention and judicious application of terraform state rm
.
Also experiencing this issue, the MIG is taking a long time to create. Terraform times out, and then every operation after that hangs. If I delete the instance (but not the MIG) I get that error.
The causing issue for this for me was that I was not specifying subnetwork when I needed to - it seems like stuff like this causes this terraform module to go into an unrecoverable state.
Using terraform to create nat-gateway using this module. https://registry.terraform.io/modules/GoogleCloudPlatform/nat-gateway/google/1.1.3
using this code :
Other snippets :
================
Above errror coming up and whole terraform script get stop , and unable to run
terraform apply
orterraform destroy
at any changes,any possible issue causing this ?