January 20, 2020

Find marketplace image names on GCP for Terraform

Finding image project and image names on GCP can be tricky. To create an instance from a marketplace image in Terraform the image ID must be specified as follows:

 default = "projects/<project>/global/images/<image name>"

For Example:

 default = "projects/centos-cloud/global/images/centos-7-v20191210"

To find the project name navigate to the marketplace webpage of the image to want to use in terraform. Here you will see the project name and family ID in the URL

After grabing the project ID head over to https://cloud.google.com/compute/docs/reference/rest/v1/images/getFromFamily? and input the project and family ids

Authenticate and then you will get the JSON output with the various published images

{
  "id": "3266424082234020029",
  "creationTimestamp": "2019-12-18T14:55:15.362-08:00",
  "name": "centos-7-v20191210",
  "description": "CentOS, CentOS, 7, x86_64 built on 20191210",
  "sourceType": "RAW",
  "rawDisk": {
    "source": "",
    "containerType": "TAR"
  },
  "status": "READY",
  "archiveSizeBytes": "16535168000",
  "diskSizeGb": "10",
  "licenses": [
    "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/licenses/centos-7"
  ],
  "family": "centos-7",
  "selfLink": "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-7-v20191210",
  

The image id will be verything after /v1/  in selfLink for example:

/projects/centos-cloud/global/images/centos-7-v20191210

See Also:

Find marketplace image names on GCP for Terraform
Finding image project and image names on GCP can be tricky. To create an instance from a marketplace image in Terraform the image ID must be specified as follows: