2016-07-07 17:50:46 -04:00
|
|
|
---
|
2017-06-14 21:04:16 -04:00
|
|
|
description: |
|
|
|
|
The Google Compute Image Exporter post-processor exports an image from a
|
|
|
|
Packer googlecompute builder run and uploads it to Google Cloud Storage. The
|
|
|
|
exported images can be easily shared and uploaded to other Google Cloud
|
|
|
|
Projects.
|
2016-07-07 17:50:46 -04:00
|
|
|
layout: docs
|
2017-06-14 21:04:16 -04:00
|
|
|
page_title: 'Google Compute Image Exporter - Post-Processors'
|
|
|
|
sidebar_current: 'docs-post-processors-googlecompute-export'
|
2017-03-25 18:13:52 -04:00
|
|
|
---
|
2016-07-07 17:50:46 -04:00
|
|
|
|
2016-10-26 13:27:07 -04:00
|
|
|
# Google Compute Image Exporter Post-Processor
|
2016-07-07 17:50:46 -04:00
|
|
|
|
|
|
|
Type: `googlecompute-export`
|
|
|
|
|
|
|
|
The Google Compute Image Exporter post-processor exports the resultant image from a
|
|
|
|
googlecompute build as a gzipped tarball to Google Cloud Storage (GCS).
|
|
|
|
|
|
|
|
The exporter uses the same Google Cloud Platform (GCP) project and authentication
|
|
|
|
credentials as the googlecompute build that produced the image. A temporary VM is
|
|
|
|
started in the GCP project using these credentials. The VM mounts the built image as
|
|
|
|
a disk then dumps, compresses, and tars the image. The VM then uploads the tarball
|
|
|
|
to the provided GCS `paths` using the same credentials.
|
|
|
|
|
|
|
|
As such, the authentication credentials that built the image must have write
|
|
|
|
permissions to the GCS `paths`.
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
### Required
|
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
- `paths` (list of string) - The list of GCS paths, e.g.
|
2016-07-07 17:50:46 -04:00
|
|
|
'gs://mybucket/path/to/file.tar.gz', where the image will be exported.
|
|
|
|
|
|
|
|
### Optional
|
|
|
|
|
2017-10-16 12:11:33 -04:00
|
|
|
- `keep_input_artifact` (boolean) - If true, do not delete the Google Compute Engine
|
2016-07-07 17:50:46 -04:00
|
|
|
(GCE) image being exported.
|
2016-10-26 13:27:07 -04:00
|
|
|
|
2016-07-07 17:50:46 -04:00
|
|
|
## Basic Example
|
|
|
|
|
2016-10-26 13:27:07 -04:00
|
|
|
The following example builds a GCE image in the project, `my-project`, with an
|
2016-07-07 17:50:46 -04:00
|
|
|
account whose keyfile is `account.json`. After the image build, a temporary VM will
|
2016-10-26 13:27:07 -04:00
|
|
|
be created to export the image as a gzipped tarball to
|
|
|
|
`gs://mybucket1/path/to/file1.tar.gz` and `gs://mybucket2/path/to/file2.tar.gz`.
|
2016-07-07 17:50:46 -04:00
|
|
|
`keep_input_artifact` is true, so the GCE image won't be deleted after the export.
|
|
|
|
|
|
|
|
In order for this example to work, the account associated with `account.json` must
|
|
|
|
have write access to both `gs://mybucket1/path/to/file1.tar.gz` and
|
|
|
|
`gs://mybucket2/path/to/file2.tar.gz`.
|
|
|
|
|
2017-06-14 21:04:16 -04:00
|
|
|
``` json
|
2016-07-07 17:50:46 -04:00
|
|
|
{
|
|
|
|
"builders": [
|
|
|
|
{
|
|
|
|
"type": "googlecompute",
|
|
|
|
"account_file": "account.json",
|
|
|
|
"project_id": "my-project",
|
|
|
|
"source_image": "debian-7-wheezy-v20150127",
|
|
|
|
"zone": "us-central1-a"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"post-processors": [
|
|
|
|
{
|
|
|
|
"type": "googlecompute-export",
|
|
|
|
"paths": [
|
|
|
|
"gs://mybucket1/path/to/file1.tar.gz",
|
|
|
|
"gs://mybucket2/path/to/file2.tar.gz"
|
2017-03-25 18:13:52 -04:00
|
|
|
],
|
2016-07-07 17:50:46 -04:00
|
|
|
"keep_input_artifact": true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
```
|