hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.29k stars 1.72k forks source link

data google_compute_instance_group broken with self_link #4628

Open mastercactapus opened 4 years ago

mastercactapus commented 4 years ago

Community Note

Terraform Version

Terraform v0.12.10
+ provider.azurerm v1.35.0
+ provider.google v2.16.0
+ provider.kubernetes v1.9.0

Affected Resource(s)

Terraform Configuration Files

data "google_compute_instance_group" "example" {
  self_link = "foo" // foo is just for illustration, but does trigger the error
}

Expected Behavior

Data-source should be loaded when using a valid self_link.

Actual Behavior

An error saying a zone is required is returned.

Error: A zone must be specified

Specifying zone, whilst defeating the purpose of self_link, indicates they shouldn't be used together:

Error: "self_link": conflicts with zone
Error: "zone": conflicts with self_link

Steps to Reproduce

  1. Define a google_compute_instance_group data-source using self_link
  2. Run terraform refresh
rileykarson commented 4 years ago

Can you share the value you've specified? A self_link looks like https://www.googleapis.com/compute/beta/projects/my-project/zones/us-central1-f/instanceGroups/my-ig while the "foo" string provided would be a name. In my example, that would be my-ig.

mastercactapus commented 4 years ago

Originally I was using instance_group_urls from a google_container_node_pool when I first got the error:

rileykarson commented 4 years ago

Sorry, the notification for this response got eaten and I missed your update. Are you still encountering the issue?

I'm surprised by the format being returned, I haven't seen that one before. Is there anything unusual about your environment you can think of?

weargoggles commented 4 years ago

I'm encountering this today. The datasource read delegates to the resource read, and the resource read always validates the zone.

weargoggles commented 4 years ago

Oh, it seems by the time the resource read validates it that it should have been set…

weargoggles commented 4 years ago

The instance_group_urls of a google_container_node_pool appear to be the URLs for instance group managers not instance groups: https://github.com/terraform-providers/terraform-provider-google/blob/1b413bc/google/resource_container_node_pool.go#L491

nemani commented 4 years ago

Bump! This issue still exists!

rileykarson commented 4 years ago

Sorry, managed to lose track of the issue again. I won't be able to get to it- unassigning so someone else on the team can pick it up.