builder/amazon/chroot: delete the EBS volume after we're done

This commit is contained in:
Mitchell Hashimoto 2013-07-29 18:17:27 -07:00
parent e5f0cbe298
commit 3f49f1a6d0
1 changed files with 14 additions and 1 deletions

View File

@ -63,4 +63,17 @@ func (s *StepCreateVolume) Run(state map[string]interface{}) multistep.StepActio
return multistep.ActionContinue
}
func (s *StepCreateVolume) Cleanup(map[string]interface{}) {}
func (s *StepCreateVolume) Cleanup(state map[string]interface{}) {
if s.volumeId == "" {
return
}
ec2conn := state["ec2"].(*ec2.EC2)
ui := state["ui"].(packer.Ui)
ui.Say("Deleting the created EBS volume...")
_, err := ec2conn.DeleteVolume(s.volumeId)
if err != nil {
ui.Error(fmt.Sprintf("Error deleting EBS volume: %s", err))
}
}