You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.
This is quite limited, as it only supports returning exactly one image, and when used with the filter argument, this filter must be crafted so that it returns a single result.My current limitation is that I'm uploading custom images to Google Compute Engine, and they are labeled with their operating system and build date. We are also developing an internal module that should allow our developers to specify what image to use with two variables, OS name and build date (nullable). We architected it this way so that devs have some flexibility: if they know the exact image they want to use, they would specify it's build date but, if they don't mind using a specific "version", they would keep that variable as null and the latest built image should be used.
As the google_compute_image datasource requires a single image to be returned, I find impossible to develop the module so it allows this second execution mode. A datasource that allows to return more than one image would solve this, as we could select our desired image sorting it in Terraform logic.
This should not be too hard to implement, as it's logic is the same as the existing datasource, but returning an images list attribute with each element an object with the same structure as the google_compute_image datasource. I could even try to submit a PR if there is interest in this feature.
New or Affected Resource(s)
data.google_compute_image
Potential Terraform Configuration
data"google_compute_images""example" {
filter="filter returning more than one image"
}
locals {
# Image selection could be as complex as requiredselected_image=data.google_compute_images.example.images[0]
}
resource"google_compute_instance""example" {
boot_disk {
initialize_params {
# Each image in the images attribute 100% follows the# specification of the google_compute_image datasourceimage=local.selected_image.self_link
}
}
}
Another execution possibility would be returning all images by family, instead of the latest one:
Community Note
Description
Currently, the only way to retrieve existing Compute Images is with the
google_compute_image
datasource: https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_imageThis is quite limited, as it only supports returning exactly one image, and when used with the
filter
argument, this filter must be crafted so that it returns a single result.My current limitation is that I'm uploading custom images to Google Compute Engine, and they are labeled with their operating system and build date. We are also developing an internal module that should allow our developers to specify what image to use with two variables, OS name and build date (nullable). We architected it this way so that devs have some flexibility: if they know the exact image they want to use, they would specify it's build date but, if they don't mind using a specific "version", they would keep that variable as null and the latest built image should be used.As the
google_compute_image
datasource requires a single image to be returned, I find impossible to develop the module so it allows this second execution mode. A datasource that allows to return more than one image would solve this, as we could select our desired image sorting it in Terraform logic.This should not be too hard to implement, as it's logic is the same as the existing datasource, but returning an
images
list attribute with each element an object with the same structure as thegoogle_compute_image
datasource. I could even try to submit a PR if there is interest in this feature.New or Affected Resource(s)
Potential Terraform Configuration
Another execution possibility would be returning all images by
family
, instead of the latest one:And even a
deprecated
parameter could be added so it adds up to thefilter
orfamily
paremeters.b/356688105
The text was updated successfully, but these errors were encountered: