builder/amazonebs: Wait for instance to terminate during cleanup

pull/919/head
Mitchell Hashimoto 13 years ago
parent 2a49088785
commit a7a51f1d8f

@ -65,5 +65,9 @@ func (s *stepRunSourceInstance) Cleanup(state map[string]interface{}) {
ui.Say("Terminating the source AWS instance...")
if _, err := ec2conn.TerminateInstances([]string{s.instance.InstanceId}); err != nil {
ui.Error(fmt.Sprintf("Error terminating instance, may still be around: %s", err))
return
}
pending := []string{"pending", "running", "shutting-down", "stopped", "stopping"}
waitForState(ec2conn, s.instance, pending, "terminated")
}

@ -67,6 +67,7 @@ func (s *stepSecurityGroup) Cleanup(state map[string]interface{}) {
ui.Say("Deleting temporary security group...")
_, err := ec2conn.DeleteSecurityGroup(ec2.SecurityGroup{Id: s.groupId})
if err != nil {
log.Printf("Error deleting security group: %s", err)
ui.Error(fmt.Sprintf(
"Error cleaning up security group. Please delete the group manually: %s", s.groupId))
}

Loading…
Cancel
Save