Open mr0re1 opened 3 months ago
Hi @mr0re1!
According to the terraform code you are sharing you didn't specify the argument share_settings
and for this reason this value was set to null. You may need to check terraform registry to see how to set a value for this argument.
As terraform registry specifies this is an optional value, and you can see the same in the Google Cloud Documentation. Only if you want to create a shared reservation you need to declare it.
In this other link you can check how to create a reservation according to your needs.
Finally I let you this other link to learn how reservations work, requirements, restrictions and so on
Hi @ggtisc ,
In my example I don't create any reservation but fetch the details about existing one:
**data** "google_compute_reservation" "reservation"
My expectations is that data source would return an accurate and complete information about the entity, including share_settings
.
Does your existing google_compute_reservation
called reservation
have the share_settings
declared?
In case that this argument isn't declared you need 1st to update it and specify its value, because as the documentation explains it is optional and if you didn't declare a value for it it is going to return always the same.
Hi @ggtisc , to illustrate the problem, I've created two reservations with different (at least one is non-default) shareSettings
:
$ gcloud compute reservations describe --project=X --zone=Y Z_SHARED --format=json | jq ".shareSettings"
{
"projectMap": {
"333333333333": {
"projectId": "333333333333"
}
},
"shareType": "SPECIFIC_PROJECTS"
}
$ gcloud compute reservations describe --project=X --zone=Y Z_LOCAL --format=json | jq ".shareSettings"
{
"shareType": "LOCAL"
}
But data "google_compute_reservation"
fails to "describe" the difference:
data "google_compute_reservation" "z_shared" {
name = "Z_SHARED"
zone = "Y"
project = "X"
}
data "google_compute_reservation" "z_local" {
name = "Z_LOCAL"
zone = "Y"
project = "X"
}
output "z_shared" {
value = data.google_compute_reservation.z_shared
}
output "z_local" {
value = data.google_compute_reservation.z_local
}
# Outputs:
z_local = {
...
"share_settings" = tolist(null) /* of object */
...
}
z_shared = {
...
"share_settings" = tolist(null) /* of object */
...
}
Confirmed issue!
For an existing google_compute_reservation
resource with share_settings
configured, after running a terraform apply
it doesn't return the assigned value, and instead of this it just returns "share_settings" = tolist(null)
Community Note
Terraform Version & Provider Version(s)
Terraform v1.4.0 on linux_amd64
Affected Resource(s)
data google_compute_reservation
Terraform Configuration
Debug Output
Expected Behavior
share_settings
contains details ofshareSettings
API field, such as:Or
Actual Behavior
Steps to reproduce
terraform apply
Important Factoids
No response
References
No response
b/343772844