hashicorp / hashicorp/packer-plugin-googlecompute
User created custom image is not found error while running the packer code on GCP
- Dominant language
- Go
- Stars
- 33
- Forks
- 72
- Avg merge
- 6h 47m
- Merged PRs (30d)
- 3
Description
I have created the custom image using packer from the public image `ubuntu-1804-bionic-v20210825` and try to create the next custom image from the custom image but getting the error `Error getting source image for instance creation: Could not find image`. The issue is intermittent and it's succeed sometime but getting failed most of the times.
I am using the latest packer and gcloud version on my Mac. I try the same on both gcloud version 355 and 356 version. Please find the details below:
$ packer --version
`1.7.4`
$ gcloud --version
- Google Cloud SDK 356.0.0
- beta 2021.09.03
- bq 2.0.71
- core 2021.09.03
- gsutil 4.67
Used packer code:
`{
"type": "googlecompute",
"account_file": "/Users/someshp/key.json",
"project_id": "{{ user `gcp_project_id` }}",
"source_image": "{{ user `gcp_source_image` }}",
"source_image_family": "{{ user `gcp_image_family` }}",
"source_image_project_id": "{{ user `gcp_project_id` }}",
"machine_type": "{{ user `gcp_machine_type` }}",
"ssh_username": "ubuntu",
"ssh_timeout": "5m",
"region": "{{ user `gcp_region` }}",
"zone": "{{ user `gcp_zone` }}",
"network": "{{ user `gcp_network` }}",
"subnetwork": "{{ user `gcp_subnetwork` }}",
"image_name": "{{ user `prefix` }}-ami-ubuntu-{{ user `ubuntu_codename` }}-{{ user `ubuntu_version` }}-{{ user `golden_image_version` }}-{{ isotime | clean_resource_name }}",
"image_family": "{{ user `gcp_image_family` }}",
"image_description": "{{ user `image_description` }}",
"image_labels": {
"os_version": "ubuntu",
"release": "{{ user `ubuntu_codename` }}-{{ user `ubuntu_version` }}"
}
}
`
Getting the below error while try to fetch the existing custom image which is created by packer.
==> googlecompute: Checking image does not exist...
==> googlecompute: Creating temporary RSA SSH key for instance...
==> googlecompute: Error getting source image for instance creation: Could not find image, golden-gcp-ami-ubuntu-bionic-1804-v1-0-1-2021-09-08t06-39-45z, in projects, [mist-freestyle-staging]: 1 error(s) occurred:
==> googlecompute:
==> googlecompute: * Get "https://compute.googleapis.com/compute/v1/projects/mist-freestyle-staging/global/images/golden-gcp-ami-ubuntu-bionic-1804-v1-0-1-2021-09-08t06-39-45z?alt=json&prettyPrint=false": oauth2: cannot fetch token: unexpected EOF
Build 'googlecompute' errored after 1 second 867 milliseconds: Error getting source image for instance creation: Could not find image, golden-gcp-ami-ubuntu-bionic-1804-v1-0-1-2021-09-08t06-39-45z, in projects, [mist-freestyle-staging]: 1 error(s) occurred:
* Get "https://compute.googleapis.com/compute/v1/projects/mist-freestyle-staging/global/images/golden-gcp-ami-ubuntu-bionic-1804-v1-0-1-2021-09-08t06-39-45z?alt=json&prettyPrint=false": oauth2: cannot fetch token: unexpected EOF
==> Wait completed after 1 second 867 milliseconds
==> Some builds didn't complete successfully and had errors:
--> googlecompute: Error getting source image for instance creation: Could not find image, golden-gcp-ami-ubuntu-bionic-1804-v1-0-1-2021-09-08t06-39-45z, in projects, [mist-freestyle-staging]: 1 error(s) occurred:
* Get "https://compute.googleapis.com/compute/v1/projects/mist-freestyle-staging/global/images/golden-gcp-ami-ubuntu-bionic-1804-v1-0-1-2021-09-08t06-39-45z?alt=json&prettyPrint=false": oauth2: cannot fetch token: unexpected EOF
==> Builds finished but no artifacts were created.
Contributor guide
Assessment
This issue has not been assessed yet.