0

I am trying to create an instance group using the example in the terraform doc at https://www.terraform.io/docs/providers/google/r/compute_instance_group.html .

resource "google_compute_instance_group" "test" {
  name        = "terraform-test"
  description = "Terraform test instance group"
  zone        = "us-central1-a"
  network     = "${google_compute_network.default.self_link}"
  project ="xyz-project"

I get the following error:

Error: resource 'google_compute_instance_group.test' config: unknown resource 'google_compute_network.default' referenced in variable google_compute_network.default.self_link

I've tried adding the following and get the same error.

data "google_compute_network" "default" {
  name = "default-us-east1"

Does anyone have a working example to create an instance group?

0

I was able to create an instance group using the following example which uses terraform. However, instruction in the example will also create TCP LB. You can refrain from creating the LB. Here are some additional tutorials using terraform [1,2,3] which might help you understand better.

|improve this answer|||||
0

If you use

data "google_compute_network" "default" {

That means its created outside of terraform. It finds it and pulls it in via an API call. So in your google_compute_instance_group you need to make it

  network     = "${data.google_compute_network.default.self_link}"

Notice the data before google. This tells terraform its a datasource lookup and not a resource terraform is managing.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.