From 33b4f5cc0a577ee8ac351e855e2713298f10c054 Mon Sep 17 00:00:00 2001 From: James Nugent Date: Wed, 15 Apr 2015 11:49:29 -0700 Subject: [PATCH] Check for EBS being nil before assigning it --- builder/amazon/chroot/step_register_ami.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/builder/amazon/chroot/step_register_ami.go b/builder/amazon/chroot/step_register_ami.go index 88da65e9f..25b87592a 100644 --- a/builder/amazon/chroot/step_register_ami.go +++ b/builder/amazon/chroot/step_register_ami.go @@ -25,7 +25,11 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { for i, device := range image.BlockDeviceMappings { newDevice := device if newDevice.DeviceName == image.RootDeviceName { - newDevice.EBS.SnapshotID = &snapshotId + if newDevice.EBS != nil { + newDevice.EBS.SnapshotID = &snapshotId + } else { + newDevice.EBS = &ec2.EBSBlockDevice{SnapshotID: &snapshotId} + } } blockDevices[i] = newDevice