fix ordering of deleting security rules and lists
This commit is contained in:
parent
76ea73c5b2
commit
1fffbacdd3
|
@ -20,7 +20,6 @@ func (s *stepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
|
||||||
keyName := state.Get("key_name").(string)
|
keyName := state.Get("key_name").(string)
|
||||||
|
|
||||||
ipAddName := fmt.Sprintf("ipres_%s", config.ImageName)
|
ipAddName := fmt.Sprintf("ipres_%s", config.ImageName)
|
||||||
// secListName := "Megan_packer_test" // hack to get working; fix b4 release
|
|
||||||
secListName := state.Get("security_list").(string)
|
secListName := state.Get("security_list").(string)
|
||||||
|
|
||||||
netInfo := compute.NetworkingInfo{
|
netInfo := compute.NetworkingInfo{
|
||||||
|
|
|
@ -71,23 +71,26 @@ func (s *stepSecurity) Cleanup(state multistep.StateBag) {
|
||||||
client := state.Get("client").(*compute.ComputeClient)
|
client := state.Get("client").(*compute.ComputeClient)
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
ui.Say("Deleting the packer-generated security rules and lists...")
|
ui.Say("Deleting the packer-generated security rules and lists...")
|
||||||
// delete security list that Packer generated
|
|
||||||
secListName := state.Get("security_list").(string)
|
|
||||||
secListClient := client.SecurityLists()
|
|
||||||
input := compute.DeleteSecurityListInput{Name: secListName}
|
|
||||||
err := secListClient.DeleteSecurityList(&input)
|
|
||||||
if err != nil {
|
|
||||||
ui.Say(fmt.Sprintf("Error deleting the packer-generated security list %s; "+
|
|
||||||
"please delete manually. (error : %s)", secListName, err.Error()))
|
|
||||||
}
|
|
||||||
// delete security rules that Packer generated
|
// delete security rules that Packer generated
|
||||||
secRuleName := state.Get("security_rule_name").(string)
|
secRuleName := state.Get("security_rule_name").(string)
|
||||||
secRulesClient := client.SecRules()
|
secRulesClient := client.SecRules()
|
||||||
ruleInput := compute.DeleteSecRuleInput{Name: secRuleName}
|
ruleInput := compute.DeleteSecRuleInput{Name: secRuleName}
|
||||||
err = secRulesClient.DeleteSecRule(&ruleInput)
|
err := secRulesClient.DeleteSecRule(&ruleInput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ui.Say(fmt.Sprintf("Error deleting the packer-generated security rule %s; "+
|
ui.Say(fmt.Sprintf("Error deleting the packer-generated security rule %s; "+
|
||||||
"please delete manually. (error: %s)", secRuleName, err.Error()))
|
"please delete manually. (error: %s)", secRuleName, err.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete security list that Packer generated
|
||||||
|
secListName := state.Get("security_list").(string)
|
||||||
|
secListClient := client.SecurityLists()
|
||||||
|
input := compute.DeleteSecurityListInput{Name: secListName}
|
||||||
|
err = secListClient.DeleteSecurityList(&input)
|
||||||
|
if err != nil {
|
||||||
|
ui.Say(fmt.Sprintf("Error deleting the packer-generated security list %s; "+
|
||||||
|
"please delete manually. (error : %s)", secListName, err.Error()))
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue