diff --git a/CHANGELOG.md b/CHANGELOG.md index 7756faed6..8263a0ee7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ IMPROVEMENTS: BUG FIXES: +* builder/amazon/ebs,instance: Retry deleing security group a few times. + [GH-278] * builder/vmware: Workstation works on Windows XP now. [GH-238] * builder/vmware: Look for files on Windows in multiple locations using multiple environmental variables. [GH-263] diff --git a/builder/amazon/common/step_security_group.go b/builder/amazon/common/step_security_group.go index 5b01a68f1..04c9b9dcf 100644 --- a/builder/amazon/common/step_security_group.go +++ b/builder/amazon/common/step_security_group.go @@ -8,6 +8,7 @@ import ( "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" "log" + "time" ) type StepSecurityGroup struct { @@ -83,9 +84,18 @@ func (s *StepSecurityGroup) Cleanup(state map[string]interface{}) { ui := state["ui"].(packer.Ui) ui.Say("Deleting temporary security group...") - _, err := ec2conn.DeleteSecurityGroup(ec2.SecurityGroup{Id: s.createdGroupId}) + + var err error + for i := 0; i < 5; i++ { + _, err = ec2conn.DeleteSecurityGroup(ec2.SecurityGroup{Id: s.createdGroupId}) + if err != nil { + log.Printf("Error deleting security group: %s", err) + time.Sleep(5 * time.Second) + continue + } + } + 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.createdGroupId)) }