From 60428cef604e3b4ac8cc5e68989d9f47b90841eb Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Mon, 21 Oct 2013 08:01:34 -0700 Subject: [PATCH 1/2] builder/amazon/ebs: Add config for target AZ. Fixes [GH-536] --- CHANGELOG.md | 3 +++ builder/amazon/common/run_config.go | 2 ++ builder/amazon/ebs/builder.go | 1 + website/source/docs/builders/amazon-ebs.html.markdown | 3 +++ 4 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea19b59ab..48f85df99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ## 0.4.0 (unreleased) +FEATURES: +* builder/amazon/ebs: Ability to specify which availability zone to create + instance in. [GH-536] ## 0.3.10 (October 20, 2013) diff --git a/builder/amazon/common/run_config.go b/builder/amazon/common/run_config.go index b21999260..8025cf0f0 100644 --- a/builder/amazon/common/run_config.go +++ b/builder/amazon/common/run_config.go @@ -23,6 +23,7 @@ type RunConfig struct { SubnetId string `mapstructure:"subnet_id"` TemporaryKeyPairName string `mapstructure:"temporary_key_pair_name"` VpcId string `mapstructure:"vpc_id"` + AvailZone string `mapstructure:"avail_zone"` // Unexported fields that are calculated from others sshTimeout time.Duration @@ -83,6 +84,7 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error { "subnet_id": &c.SubnetId, "temporary_key_pair_name": &c.TemporaryKeyPairName, "vpc_id": &c.VpcId, + "avail_zone": &c.AvailZone, } for n, ptr := range templates { diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 376a90e2b..f646d694f 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -101,6 +101,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe SourceAMI: b.config.SourceAmi, IamInstanceProfile: b.config.IamInstanceProfile, SubnetId: b.config.SubnetId, + AvailZone: b.config.AvailZone, BlockDevices: b.config.BlockDevices, }, &common.StepConnectSSH{ diff --git a/website/source/docs/builders/amazon-ebs.html.markdown b/website/source/docs/builders/amazon-ebs.html.markdown index 7248a2e2d..58d1dbcd7 100644 --- a/website/source/docs/builders/amazon-ebs.html.markdown +++ b/website/source/docs/builders/amazon-ebs.html.markdown @@ -120,6 +120,9 @@ Optional: * `vpc_id` (string) - If launching into a VPC subnet, Packer needs the VPC ID in order to create a temporary security group within the VPC. +* `avail_zone` (string) - Destination availability zone to launch instance in. + Leave this empty to allow Amazon to auto-assign.. + ## Basic Example Here is a basic example. It is completely valid except for the access keys: From 1aa551a49c8184f85d546af5910c30952ecbf464 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Mon, 21 Oct 2013 08:08:00 -0700 Subject: [PATCH 2/2] builder/amazon/common: Add AvailZone to StepRunSourceInstance struct [GH-536] --- builder/amazon/common/step_run_source_instance.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builder/amazon/common/step_run_source_instance.go b/builder/amazon/common/step_run_source_instance.go index 4aeab217c..5d26f8c69 100644 --- a/builder/amazon/common/step_run_source_instance.go +++ b/builder/amazon/common/step_run_source_instance.go @@ -18,6 +18,7 @@ type StepRunSourceInstance struct { SourceAMI string IamInstanceProfile string SubnetId string + AvailZone string BlockDevices BlockDevices instance *ec2.Instance @@ -51,6 +52,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi IamInstanceProfile: s.IamInstanceProfile, SubnetId: s.SubnetId, BlockDevices: s.BlockDevices.BuildLaunchDevices(), + AvailZone: s.AvailZone, } ui.Say("Launching a source AWS instance...")