diff --git a/builder/googlecompute/config.go b/builder/googlecompute/config.go index 99c52a704..c4aa79d22 100644 --- a/builder/googlecompute/config.go +++ b/builder/googlecompute/config.go @@ -36,6 +36,7 @@ type Config struct { ImageDescription string `mapstructure:"image_description"` ImageFamily string `mapstructure:"image_family"` InstanceName string `mapstructure:"instance_name"` + Labels map[string]string `mapstructure:"labels"` MachineType string `mapstructure:"machine_type"` Metadata map[string]string `mapstructure:"metadata"` Network string `mapstructure:"network"` diff --git a/builder/googlecompute/driver.go b/builder/googlecompute/driver.go index a93559e92..60707ac84 100644 --- a/builder/googlecompute/driver.go +++ b/builder/googlecompute/driver.go @@ -65,6 +65,7 @@ type InstanceConfig struct { DiskSizeGb int64 DiskType string Image *Image + Labels map[string]string MachineType string Metadata map[string]string Name string diff --git a/builder/googlecompute/driver_gce.go b/builder/googlecompute/driver_gce.go index 28cb08f6a..0df21eba6 100644 --- a/builder/googlecompute/driver_gce.go +++ b/builder/googlecompute/driver_gce.go @@ -407,6 +407,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) { }, }, GuestAccelerators: guestAccelerators, + Labels: c.Labels, MachineType: machineType.SelfLink, Metadata: &compute.Metadata{ Items: metadata, diff --git a/builder/googlecompute/step_create_instance.go b/builder/googlecompute/step_create_instance.go index 97b659a9d..a4509354e 100644 --- a/builder/googlecompute/step_create_instance.go +++ b/builder/googlecompute/step_create_instance.go @@ -106,6 +106,7 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction DiskSizeGb: c.DiskSizeGb, DiskType: c.DiskType, Image: sourceImage, + Labels: c.Labels, MachineType: c.MachineType, Metadata: metadata, Name: name, diff --git a/website/source/docs/builders/googlecompute.html.md b/website/source/docs/builders/googlecompute.html.md index c17d6a185..891dc401b 100644 --- a/website/source/docs/builders/googlecompute.html.md +++ b/website/source/docs/builders/googlecompute.html.md @@ -204,6 +204,9 @@ builder. - `instance_name` (string) - A name to give the launched instance. Beware that this must be unique. Defaults to `"packer-{{uuid}}"`. +- `labels` (object of key/value strings) - Labels applied to the launched + instance. + - `machine_type` (string) - The machine type. Defaults to `"n1-standard-1"`. - `metadata` (object of key/value strings) - Metadata applied to the launched