Commit 220d586c authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

website: document GCE auth scheme

parent b5c0c63e
...@@ -13,38 +13,27 @@ for use with [Google Compute Engine](https://cloud.google.com/products/compute-e ...@@ -13,38 +13,27 @@ for use with [Google Compute Engine](https://cloud.google.com/products/compute-e
(GCE) based on existing images. Google Compute Engine doesn't allow the creation (GCE) based on existing images. Google Compute Engine doesn't allow the creation
of images from scratch. of images from scratch.
## Setting Up API Access ## Authentication
There is a small setup step required in order to obtain the credentials Authenticating with Google Cloud services requires two separate JSON
that Packer needs to use Google Compute Engine. This needs to be done only files: one which we call the _account file_ and the _client secrets file_.
once if you intend to share the credentials.
In order for Packer to talk to Google Compute Engine, it will need Both of these files are downloaded directly from the
a _client secrets_ JSON file and a _client private key_. Both of these are [Google Developers Console](https://console.developers.google.com). To make
obtained from the [Google Cloud Console](https://cloud.google.com/console). the process more straightforwarded, it is documented here.
Follow the steps below: 1. Log into the [Google Developers Console](https://console.developers.google.com)
and select a project.
1. Log into the [Google Cloud Console](https://cloud.google.com/console) 2. Under the "APIs & Auth" section, click "Credentials."
2. Click on the project you want to use Packer with (or create one if you
don't have one yet).
3. Click "APIs & auth" in the left sidebar
4. Click "Credentials" in the left sidebar
5. Click "Create New Client ID" and choose "Service Account"
6. A private key will be downloaded for you. Note the password for the private key! This private key is your _client private key_.
7. After creating the account, click "Download JSON". This is your _client secrets JSON_ file. Make sure you didn't download the JSON from the "OAuth 2.0" section! This is a common mistake and will cause the builder to not work.
Finally, one last step, you'll have to convert the `p12` file you 3. Click the "Download JSON" button under the "Compute Engine and App Engine"
got from Google into the PEM format. You can do this with OpenSSL, which account in the OAuth section. The file should start with "client\_secrets".
is installed standard on most Unixes: This is your _client secrets file_.
``` 4. Create a new OAuth client ID and select "Service Account" as the type
$ openssl pkcs12 -in <path to .p12> -nocerts -passin pass:notasecret \ of account. Once created, a JSON file should be downloaded. This is your
-nodes -out private_key.pem _account file_.
```
The client secrets JSON you downloaded along with the new "private\_key.pem"
file are the two files you need to configure Packer with to talk to GCE.
## Basic Example ## Basic Example
...@@ -57,8 +46,8 @@ files obtained in the previous section. ...@@ -57,8 +46,8 @@ files obtained in the previous section.
{ {
"type": "googlecompute", "type": "googlecompute",
"bucket_name": "my-project-packer-images", "bucket_name": "my-project-packer-images",
"account_file": "account.json",
"client_secrets_file": "client_secret.json", "client_secrets_file": "client_secret.json",
"private_key_file": "XXXXXX-privatekey.p12",
"project_id": "my-project", "project_id": "my-project",
"source_image": "debian-7-wheezy-v20140718", "source_image": "debian-7-wheezy-v20140718",
"zone": "us-central1-a" "zone": "us-central1-a"
...@@ -72,6 +61,9 @@ each category, the available options are alphabetized and described. ...@@ -72,6 +61,9 @@ each category, the available options are alphabetized and described.
### Required: ### Required:
* `account_file` (string) - The JSON file containing your account credentials.
Instructions for how to retrieve these are above.
* `bucket_name` (string) - The Google Cloud Storage bucket to store the * `bucket_name` (string) - The Google Cloud Storage bucket to store the
images that are created. The bucket must already exist in your project. images that are created. The bucket must already exist in your project.
...@@ -113,9 +105,6 @@ each category, the available options are alphabetized and described. ...@@ -113,9 +105,6 @@ each category, the available options are alphabetized and described.
* `network` (string) - The Google Compute network to use for the launched * `network` (string) - The Google Compute network to use for the launched
instance. Defaults to `default`. instance. Defaults to `default`.
* `passphrase` (string) - The passphrase to use if the `private_key_file`
is encrypted.
* `ssh_port` (integer) - The SSH port. Defaults to 22. * `ssh_port` (integer) - The SSH port. Defaults to 22.
* `ssh_timeout` (string) - The time to wait for SSH to become available. * `ssh_timeout` (string) - The time to wait for SSH to become available.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment