From fd43c27de11ac06a114553ed81c09579526f1148 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 23 Jul 2013 23:19:44 -0500 Subject: [PATCH] builder/amazon/instance: check for the ami tools --- builder/amazon/instance/step_bundle_volume.go | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/builder/amazon/instance/step_bundle_volume.go b/builder/amazon/instance/step_bundle_volume.go index e4c2eca48..a0142991c 100644 --- a/builder/amazon/instance/step_bundle_volume.go +++ b/builder/amazon/instance/step_bundle_volume.go @@ -1,14 +1,36 @@ package instance import ( + "fmt" "github.com/mitchellh/multistep" - "time" + "github.com/mitchellh/packer/packer" ) type StepBundleVolume struct{} func (s *StepBundleVolume) Run(state map[string]interface{}) multistep.StepAction { - time.Sleep(10 * time.Hour) + comm := state["communicator"].(packer.Communicator) + ui := state["ui"].(packer.Ui) + + // Verify the AMI tools are available + ui.Say("Checking for EC2 AMI tools...") + cmd := &packer.RemoteCmd{Command: "ec2-ami-tools-version"} + if err := comm.Start(cmd); err != nil { + state["error"] = fmt.Errorf("Error checking for AMI tools: %s", err) + ui.Error(state["error"].(error).Error()) + return multistep.ActionHalt + } + cmd.Wait() + + if cmd.ExitStatus != 0 { + state["error"] = fmt.Errorf( + "The EC2 AMI tools could not be detected. These must be manually\n" + + "via a provisioner or some other means and are required for Packer\n" + + "to create an instance-store AMI.") + ui.Error(state["error"].(error).Error()) + return multistep.ActionHalt + } + return multistep.ActionContinue }