From 5f92de6a395be7fea374ab3a3bf311fe8369acd9 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 23 Jun 2017 14:12:31 -0700 Subject: [PATCH] fix panic that occurs when ami_block_device_mappings and does not explicitly contain the root volume --- builder/amazon/ebssurrogate/step_register_ami.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builder/amazon/ebssurrogate/step_register_ami.go b/builder/amazon/ebssurrogate/step_register_ami.go index 2f3b9d776..0b9875308 100644 --- a/builder/amazon/ebssurrogate/step_register_ami.go +++ b/builder/amazon/ebssurrogate/step_register_ami.go @@ -25,7 +25,8 @@ func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { ui.Say("Registering the AMI...") - blockDevicesExcludingRoot := make([]*ec2.BlockDeviceMapping, 0, len(s.BlockDevices)-1) + // Defensive coding to make sure we only add the root volume once + blockDevicesExcludingRoot := make([]*ec2.BlockDeviceMapping, 0, len(s.BlockDevices)) for _, blockDevice := range s.BlockDevices { if *blockDevice.DeviceName == s.RootDevice.SourceDeviceName { continue