github.com/rothwerx/packer@v0.9.0/builder/amazon/chroot/step_check_root_device.go (about)

     1  package chroot
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/aws/aws-sdk-go/service/ec2"
     7  	"github.com/mitchellh/multistep"
     8  	"github.com/mitchellh/packer/packer"
     9  )
    10  
    11  // StepCheckRootDevice makes sure the root device on the AMI is EBS-backed.
    12  type StepCheckRootDevice struct{}
    13  
    14  func (s *StepCheckRootDevice) Run(state multistep.StateBag) multistep.StepAction {
    15  	image := state.Get("source_image").(*ec2.Image)
    16  	ui := state.Get("ui").(packer.Ui)
    17  
    18  	ui.Say("Checking the root device on source AMI...")
    19  
    20  	// It must be EBS-backed otherwise the build won't work
    21  	if *image.RootDeviceType != "ebs" {
    22  		err := fmt.Errorf("The root device of the source AMI must be EBS-backed.")
    23  		state.Put("error", err)
    24  		ui.Error(err.Error())
    25  		return multistep.ActionHalt
    26  	}
    27  
    28  	return multistep.ActionContinue
    29  }
    30  
    31  func (s *StepCheckRootDevice) Cleanup(multistep.StateBag) {}