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_guest_attributes data source returns an error if no attributes matchquery_path #20346

Closed

Comments

@quentinmit
Copy link

quentinmit commented Nov 15, 2024

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.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Terraform Version & Provider Version(s)

OpenTofu v1.8.2
on linux_amd64

  • provider registry.terraform.io/hashicorp/google v6.11.1

Affected Resource(s)

google_compute_instance_guest_attributes

Terraform Configuration

Replace $project and $name (and maybe us-east5-a) with a project and an instance that exist:

terraform {
  required_providers {
    google = {
      source = "registry.terraform.io/hashicorp/google"
    }
  }
}

provider "google" {
  project = "$project"
  region = "us-east5"
  zone = "us-east5-a"
}

data "google_compute_instance_guest_attributes" "attrs" {
  name = "$name"
  zone = "us-east5-a"
  query_path = "nonexistent/"
}

Debug Output

https://gist.github.com/quentinmit/8905c2de4ff0caa3fc10e58bbb5aa6d1

Expected Behavior

Like other data resources that query lists of things, the data resource should have been created successfully, and its query_value attribute should have contained an empty list.

Actual Behavior

The data resource fails to create with an error citing the wrong resource:

data.google_compute_instance_guest_attributes.attrs: Reading...

Planning failed. OpenTofu encountered an error while generating this plan.

╷
│ Error: projects/$project/zones/us-east5-a/instances/$name not found
│ 
│   with data.google_compute_instance_guest_attributes.attrs,
│   on main.tf line 15, in data "google_compute_instance_guest_attributes" "attrs":
│   15: data "google_compute_instance_guest_attributes" "attrs" {
│ 
╵

Note that the error message indicates that the instance does not exist. The instance does exist; there just aren't any guest attributes in the queried namespace. If you change the query to hostkeys/ (for an instance that has hostkeys attributes) it works correctly.

Steps to reproduce

  1. tofu plan

Important Factoids

No response

References

No response

b/379900319

@quentinmit quentinmit added the bug label Nov 15, 2024
@ggtisc ggtisc self-assigned this Nov 19, 2024
@ggtisc ggtisc added forward/review In review; remove label to forward service/compute-instances labels Nov 19, 2024
@ggtisc
Copy link
Collaborator

ggtisc commented Nov 19, 2024

Confirmed issue!

Even if a metadata enable-guest-attributes is used on a google_compute_instance it is not possible to use any different value for google_compute_instance_guest_attributes.query_path

resource "google_compute_instance" "c_instance_20346" {
# some code

  metadata = {
    enable-guest-attributes = "TRUE"
  }
}

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 Jan 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.