From c0b27dfa6f193f17924c2d7e88924d49b20132aa Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Thu, 25 May 2017 13:48:32 -0700 Subject: [PATCH] don't try to delete extra volumes during clean up --- builder/amazon/ebs/step_cleanup_volumes.go | 23 +++++----------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/builder/amazon/ebs/step_cleanup_volumes.go b/builder/amazon/ebs/step_cleanup_volumes.go index 29d8ffcaf..d056f5457 100644 --- a/builder/amazon/ebs/step_cleanup_volumes.go +++ b/builder/amazon/ebs/step_cleanup_volumes.go @@ -37,22 +37,8 @@ func (s *stepCleanupVolumes) Cleanup(state multistep.StateBag) { ui.Say("Cleaning up any extra volumes...") - // We don't actually care about the value here, but we need Set behavior - save := make(map[string]struct{}) - for _, b := range s.BlockDevices.AMIMappings { - if !b.DeleteOnTermination { - save[b.DeviceName] = struct{}{} - } - } - - for _, b := range s.BlockDevices.LaunchMappings { - if !b.DeleteOnTermination { - save[b.DeviceName] = struct{}{} - } - } - // Collect Volume information from the cached Instance as a map of volume-id - // to device name, to compare with save list above + // to device name, to compare with save list below var vl []*string volList := make(map[string]string) for _, bdm := range instance.BlockDeviceMappings { @@ -91,10 +77,11 @@ func (s *stepCleanupVolumes) Cleanup(state multistep.StateBag) { return } - // Filter out any devices marked for saving - for saveName := range save { + // Filter out any devices created as part of the launch mappings, since + // we'll let amazon follow the `delete_on_termination` setting. + for _, b := range s.BlockDevices.LaunchMappings { for volKey, volName := range volList { - if volName == saveName { + if volName == b.DeviceName { delete(volList, volKey) } }