github.com/askholme/packer@v0.7.2-0.20140924152349-70d9566a6852/website/source/docs/builders/googlecompute.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "Google Compute Builder" 4 --- 5 6 # Google Compute Builder 7 8 Type: `googlecompute` 9 10 The `googlecompute` builder is able to create 11 [images](https://developers.google.com/compute/docs/images) 12 for use with [Google Compute Engine](https://cloud.google.com/products/compute-engine) 13 (GCE) based on existing images. Google Compute Engine doesn't allow the creation 14 of images from scratch. 15 16 ## Authentication 17 18 Authenticating with Google Cloud services requires two separate JSON 19 files: one which we call the _account file_ and the _client secrets file_. 20 21 Both of these files are downloaded directly from the 22 [Google Developers Console](https://console.developers.google.com). To make 23 the process more straightforwarded, it is documented here. 24 25 1. Log into the [Google Developers Console](https://console.developers.google.com) 26 and select a project. 27 28 2. Under the "APIs & Auth" section, click "Credentials." 29 30 3. Click the "Download JSON" button under the "Compute Engine and App Engine" 31 account in the OAuth section. The file should start with "client\_secrets". 32 This is your _client secrets file_. 33 34 4. Create a new OAuth client ID and select "Service Account" as the type 35 of account. Once created, a JSON file should be downloaded. This is your 36 _account file_. 37 38 ## Basic Example 39 40 Below is a fully functioning example. It doesn't do anything useful, 41 since no provisioners are defined, but it will effectively repackage an 42 existing GCE image. The client secrets file and private key file are the 43 files obtained in the previous section. 44 45 <pre class="prettyprint"> 46 { 47 "type": "googlecompute", 48 "bucket_name": "my-project-packer-images", 49 "account_file": "account.json", 50 "client_secrets_file": "client_secret.json", 51 "project_id": "my-project", 52 "source_image": "debian-7-wheezy-v20140718", 53 "zone": "us-central1-a" 54 } 55 </pre> 56 57 ## Configuration Reference 58 59 Configuration options are organized below into two categories: required and optional. Within 60 each category, the available options are alphabetized and described. 61 62 ### Required: 63 64 * `account_file` (string) - The JSON file containing your account credentials. 65 Instructions for how to retrieve these are above. 66 67 * `bucket_name` (string) - The Google Cloud Storage bucket to store the 68 images that are created. The bucket must already exist in your project. 69 70 * `client_secrets_file` (string) - The client secrets JSON file that 71 was set up in the section above. 72 73 * `private_key_file` (string) - The client private key file that was 74 generated in the section above. 75 76 * `project_id` (string) - The project ID that will be used to launch instances 77 and store images. 78 79 * `source_image` (string) - The source image to use to create the new image 80 from. Example: "debian-7" 81 82 * `zone` (string) - The zone in which to launch the instance used to create 83 the image. Example: "us-central1-a" 84 85 ### Optional: 86 87 * `disk_size` (integer) - The size of the disk in GB. 88 This defaults to 10, which is 10GB. 89 90 * `image_name` (string) - The unique name of the resulting image. 91 Defaults to `packer-{{timestamp}}`. 92 93 * `image_description` (string) - The description of the resulting image. 94 95 * `instance_name` (string) - A name to give the launched instance. Beware 96 that this must be unique. Defaults to "packer-{{uuid}}". 97 98 * `machine_type` (string) - The machine type. Defaults to `n1-standard-1`. 99 100 * `metadata` (object of key/value strings) 101 <!--- 102 @todo document me 103 --> 104 105 * `network` (string) - The Google Compute network to use for the launched 106 instance. Defaults to `default`. 107 108 * `ssh_port` (integer) - The SSH port. Defaults to 22. 109 110 * `ssh_timeout` (string) - The time to wait for SSH to become available. 111 Defaults to "1m". 112 113 * `ssh_username` (string) - The SSH username. Defaults to "root". 114 115 * `state_timeout` (string) - The time to wait for instance state changes. 116 Defaults to "5m". 117 118 * `tags` (array of strings) 119 <!--- 120 @todo document me 121 --> 122 123 ## Gotchas 124 125 Centos images have root ssh access disabled by default. Set `ssh_username` to any user, which will be created by packer with sudo access. 126 127 The machine type must have a scratch disk, which means you can't use an `f1-micro` or `g1-small` to build images.