builder/amazon/ebs: clean up AMI in error [GH-1186]
This commit is contained in:
parent
669f26a108
commit
a587bd47a1
|
@ -63,6 +63,7 @@ BUG FIXES:
|
|||
* builder/amazon-chroot: Fix crash in root device check. [GH-1360]
|
||||
* builder/amazon-chroot: Add description that Packer made the snapshot
|
||||
with a time. [GH-1388]
|
||||
* builder/amazon-ebs: AMI is deregistered if an error. [GH-1186]
|
||||
* builder/amazon-instance: Fix deprecation warning for `ec2-bundle-vol`
|
||||
[GH-1424]
|
||||
* builder/amazon-instance: Add `--no-filter` to the `ec2-bundle-vol`
|
||||
|
|
|
@ -69,14 +69,17 @@ func (s *stepCreateAMI) Run(state multistep.StateBag) multistep.StepAction {
|
|||
}
|
||||
|
||||
func (s *stepCreateAMI) Cleanup(state multistep.StateBag) {
|
||||
if s.image == nil || s.image.State == "available" {
|
||||
_, cancelled := state.GetOk(multistep.StateCancelled)
|
||||
_, halted := state.GetOk(multistep.StateHalted)
|
||||
|
||||
if !cancelled && !halted {
|
||||
return
|
||||
}
|
||||
|
||||
ec2conn := state.Get("ec2").(*ec2.EC2)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
ui.Say("Deregistering the AMI ...")
|
||||
ui.Say("Deregistering the AMI because cancelation or error...")
|
||||
if resp, err := ec2conn.DeregisterImage(s.image.Id); err != nil {
|
||||
ui.Error(fmt.Sprintf("Error deregistering AMI, may still be around: %s", err))
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue