First download the json key of a existing Service Account with granted roles of:
- Compute Admin
- Service Account User
Packer looks for credentials in the following places, preferring the first location found:
-
An
account_fileoption in your packer file. -
A JSON file (Service Account) whose path is specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable.
-
A JSON file in a location known to the gcloud command-line tool. (gcloud auth application-default login creates it)
Add the right data according to your Google Cloud Platform porject settings
project_idnetworknetwork_project_idsubnetwork
Review if you need it to be preemtible, or omit_external_ip and change decriptions and names accordingly
packer validate <file-name>.json packer build <file-name>.json Check the image from Custom images menu in New VM instance Compute Engine menu