Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google_compute_instance data source returns mangled "id" field #12398

Closed
mponton-cn opened this issue Aug 26, 2022 · 2 comments · Fixed by GoogleCloudPlatform/magic-modules#6476, hashicorp/terraform-provider-google-beta#4636 or #12405
Assignees
Labels
bug forward/review In review; remove label to forward service/compute-instances

Comments

@mponton-cn
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment or link the pull request to this issue.

Terraform Version

Terraform v1.2.8
on windows_amd64

  • provider registry.terraform.io/hashicorp/google v4.33.0

NOTE: Issue reproducible on Linux as well.

Affected Resource(s)

  • google_compute_instance data source

Terraform Configuration Files (if applicable)

data "google_compute_instance" "vm" {
    name    = "REDACTED_vm_name"
    project = "REDACTED_project_id"
    zone    = "northamerica-northeast1-a"
}

output "test" {
  value = data.google_compute_instance.vm
}

Issue Description

The VM instance is properly read and available but the id field is incorrect (mangled) and looks like this:

Excerpt from the plan:

+ id = "projects/REDACTED-project-id/zones/https://www.googleapis.com/compute/v1/projects/REDACTED-project-id/zones/northamerica-northeast1-a/instances/REDACTED-vm-name"

Notice the extra https://.....

It should instead be:

+ id = "projects/REDACTED-project-id/zones/northamerica-northeast1-a/instances/REDACTED-vm-name"

Trying to use this field as a dependency for a resource will of course fail.

Important Factoids

  • When creating a new VM using a google_compute_instance resource the id field of the newly created VM is correct.
  • I can reproduce this on multiple (probably all; tried many) VMs.
  • Multiple users and service accounts have that problem (all who tried it so far).
  • I thought this might be some kind of regression so I tried older provider versions and went as far back as v3.0.0 and the id field is always mangled.
  • For now I did not notice any other field being mangled like this.
  • The instance's self_link field is correct.
  • The terraform operation messages also include the mangled id value, e.g.:
data.google_compute_instance.vm: Reading...
data.google_compute_instance.vm: Read complete after 0s [id=projects/REDACTED-project-id/zones/https://www.googleapis.com/compute/v1/projects/REDACTED-project-id/zones/northamerica-northeast1-a/instances/REDACTED-vm-name]
@mponton-cn
Copy link
Author

@edwardmedia Thanks for such a quick PR to fix this! Much appreciated.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2022
@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-instances labels Jan 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.