Also deregister AMI if it was copied to other regions
This commit is contained in:
parent
a613446205
commit
952b2c921f
@ -2,6 +2,7 @@ package common
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/mitchellh/goamz/aws"
|
||||||
"github.com/mitchellh/goamz/ec2"
|
"github.com/mitchellh/goamz/ec2"
|
||||||
"github.com/mitchellh/packer/packer"
|
"github.com/mitchellh/packer/packer"
|
||||||
"log"
|
"log"
|
||||||
@ -51,9 +52,10 @@ func (a *Artifact) String() string {
|
|||||||
func (a *Artifact) Destroy() error {
|
func (a *Artifact) Destroy() error {
|
||||||
errors := make([]error, 0)
|
errors := make([]error, 0)
|
||||||
|
|
||||||
for _, imageId := range a.Amis {
|
for region, imageId := range a.Amis {
|
||||||
log.Printf("Deregistering image ID: %s", imageId)
|
log.Printf("Deregistering image ID (%s) from region (%s)", imageId, region)
|
||||||
if _, err := a.Conn.DeregisterImage(imageId); err != nil {
|
regionconn := ec2.New(a.Conn.Auth, aws.Regions[region])
|
||||||
|
if _, err := regionconn.DeregisterImage(imageId); err != nil {
|
||||||
errors = append(errors, err)
|
errors = append(errors, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user