2

I am trying to add all the master VM instance on GCS in to a Google compute instance group via Terraform.

This is the code snipit that I use.

resource "google_compute_instance_group" "masters" {
  name        = "master-api"
  description = "Master API group"
  count = "${var.mastercount}"

  instances = ["${google_compute_instance.master.*.self_link}"]

  named_port {
    name = "api"
    port = "6443"
  }

  zone = "${"${var.region}-b"}"
}

When I apply the plan I do get my "master-api" group but I also get error output. It looks to me that is trying to make more then one group.

Error: Error applying plan:

2 error(s) occurred:

* google_compute_instance_group.masters[2]: 1 error(s) occurred:

* google_compute_instance_group.masters.2: Error creating InstanceGroup: googleapi: Error 409: The resource 'projects/appportablityphase2/zones/us-east1-b/instanceGroups/master-api' already exists, alreadyExists
* google_compute_instance_group.masters[0]: 1 error(s) occurred:

* google_compute_instance_group.masters.0: Error creating InstanceGroup: googleapi: Error 409: The resource 'projects/appportablityphase2/zones/us-east1-b/instanceGroups/master-api' already exists, alreadyExists
Grzenio
  • 35,875
  • 47
  • 158
  • 240
Andy d. H.
  • 49
  • 6
  • What happens if you run a destroy? Does the instance still stay there? If not does the error happen again if you run another apply? – ydaetskcoR May 03 '18 at 16:37
  • 1
    Well I figured it out on my own. I had to remove the count line. – Andy d. H. May 03 '18 at 16:58
  • @ydaetskcoR it destroys just fine. The problem was the count. It was trying to make more then one. – Andy d. H. May 04 '18 at 17:32
  • Can you add a proper answer where you explain the issue that you faced and your solution, it can be really useful for future users! – GalloCedrone May 07 '18 at 10:08
  • The problem here was that I had count in a group type. So it was trying to create more then one compute group. By removing the count line in the code it create just one and the problem went away. – Andy d. H. May 30 '18 at 20:01

0 Answers0