I’m trying to create a “google_compute_instance_template” using an image from my GCR registry (ideally always pulling an image with a specific tag).
It seems like I should be able to create a google_compute_image referencing gcr, then have my instance template reference that, but I can’t get it working.
I’ve tried:
data "google_compute_image" "latest-image" { name = "[my-image-name]" project = var.project }
Which gives me
Error: error retrieving image information: googleapi: Error 404: The resource ‘projects/[my-project]/global/images/[my-image-name]’ was not found, notFound
and
data "google_container_registry_image" "latest-registry-image" { name = "[my-registry-image]" project = var.project } resource "google_compute_image" "latest-image" { name = "my-image" raw_disk { source = data.google_container_registry_image.latest-registry-image.image_url } }
Which gives me:
Error: Error creating Image: googleapi: Error 400: Invalid value for field ‘resource.rawDisk.source’: ‘gcr.io/[my-project]/[my-registry-image]’. The provided source location was not a valid Google Cloud Storage object reference., invalid
What’s the correct way to do this?