Reputation: 343
Goal: Create a compute instance and add it to an unmanaged instance group in GCP using terraform.
Issue: A compute instance and an unmanaged instance group are being created successfully, but the instance is not being added to the group and giving: Error invalid instance URLs: resource "google_compute_instance_group" "t-compute-instance-group"
Able to add the instance to the group manually after running the terraform configuration though.
Service account key has Project Editor permission assigned.
Code: https://github.com/sagar-aj7/terraform_unmanaged_inst_group
Upvotes: 5
Views: 1889
Reputation: 516
I've hit the same problem, what worked for me was to use the selflink
instead of the id
:
resource "google_compute_instance_group" "backend-instances" {
name = "..."
zone = "${var.availability_zone}"
instances = ["${google_compute_instance.node.*.self_link}"]
named_port {
name = "http"
port = "8080"
}
named_port {
name = "https"
port = "8443"
}
..
}
I'm on the google provider version 2.8.0
. I guess it's time to upgrade :)
Upvotes: 10
Reputation: 94
I had the same problem today. The solution was to update the google terraform provider to a newer version (3.52.0). This fixed the issue and created the instance group with the assigned instance.
Upvotes: 0