builder/amazon-ebs: don't clean up AMI if doesn't exist [GH-1469]

This commit is contained in:
Mitchell Hashimoto 2014-09-08 09:52:49 -07:00
parent 984b8835ca
commit dc0de7da49
1 changed files with 4 additions and 1 deletions

View File

@ -69,9 +69,12 @@ func (s *stepCreateAMI) Run(state multistep.StateBag) multistep.StepAction {
}
func (s *stepCreateAMI) Cleanup(state multistep.StateBag) {
if s.image == nil {
return
}
_, cancelled := state.GetOk(multistep.StateCancelled)
_, halted := state.GetOk(multistep.StateHalted)
if !cancelled && !halted {
return
}