Skip to content
A Packer builder for Google Compute
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Google Compute Builder

Build Status

Type: googlecompute

The googlecompute builder is able to create new images for use with Google Compute Engine.


Download a binary release from Github. Extract then copy the packer-builder-googlecompute binary to the Packer installation directory.

cp packer-builder-googlecompute /usr/local/packer/

Packer version v0.3.11+ required.


Enable the googlecompute builder in ~/.packerconfig

  "builders": {
    "googlecompute": "/usr/local/packer/packer-builder-googlecompute"

See configure Packer for more info.

GCE Credentials

The googlecompute builder requires a GCE service account.

The client_secrets.json and privatekey.p12 are required:

  • XXXXXX-privatekey.p12

The client_secrets.json file can be downloaded from the Cloud Console under the API & auth (Registered apps) section. Click on a service account, then on the next sscreen click the "Downlad JSON" button.

The XXXXXX-privatekey.p12 must be converted to pem format. This can be done using the openssl commandline tool:

openssl pkcs12 -in XXXXXX-privatekey.p12 -out XXXXXX-privatekey.pem

When prompted for "Enter Import Password", enter notasecret.

GCE Permissions

API permissions needed:

  • Google Storage API
  • Google Storage JSON API
  • Google Compute Engine

Google Cloud Storage Bucket

Create a bucket where GCE images will be stored and ensure its permissions are available to your service app.

Basic Example

  "builders": [{
    "type": "googlecompute",
    "bucket_name": "packer-images",
    "client_secrets_file": "",
    "private_key_file": "XXXXXX-privatekey.pem",
    "project_id": "my-project",
    "source_image": "debian-7-wheezy-v20131014",
    "zone": "us-central1-a"

Configuration Reference

The reference of available configuration options is listed below.

Required parameters:

  • bucket_name (string) - The Google Cloud Storage bucket to store images.
  • client_secrets_file (string) - The client secrets file.
  • private_key_file (string) - The service account private key.
  • project_id (string) - The GCE project id.
  • source_image (string) - The source image. Example debian-7-wheezy-v20131014.
  • zone (string) - The GCE zone.

Optional parameters:

  • image_name (string) - The unique name of the resulting image. Defaults to packer-{{timestamp}}.
  • image_description (string) - The description of the resulting image.
  • machine_type (string) - The machine type. Defaults to n1-standard-1.
  • network (string) - The Google Compute network. Defaults to default.
  • passphrase (string) - The passphrase to use if the private_key_file is encrypted.
  • ssh_port (int) - The SSH port. Defaults to 22.
  • ssh_timeout (string) - The time to wait for SSH to become available. Defaults to 1m.
  • ssh_username (string) - The SSH username. Defaults to root.
  • state_timeout (string) - The time to wait for instance state changes. Defaults to 5m.

The machine type must have a scratch disk, which means you can't use an f1-micro or g1-small to build images. Centos images have root ssh access disabled by default. Set ssh_username to any user, which will be created by packer with sudo access.


Clone this repository into $GOPATH/src/ Then build the packer-builder-googlecompute binary:

cd $GOPATH/src/
go get
go build

Copy the results to the Packer install directory.

cp packer-builder-googlecompute /usr/local/packer/packer-builder-googlecompute
Something went wrong with that request. Please try again.