Skip to content

Commit

Permalink
Log accurate number of AMIs deleted (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
StandB authored Apr 1, 2021
1 parent 67a87cf commit 37e1170
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion aws/ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func nukeAllAMIs(session *session.Session, imageIds []*string) error {

logging.Logger.Infof("Deleting all AMIs in region %s", *session.Config.Region)

deletedCount := 0
for _, imageID := range imageIds {
params := &ec2.DeregisterImageInput{
ImageId: imageID,
Expand All @@ -59,10 +60,11 @@ func nukeAllAMIs(session *session.Session, imageIds []*string) error {
if err != nil {
logging.Logger.Errorf("[Failed] %s", err)
} else {
deletedCount++
logging.Logger.Infof("Deleted AMI: %s", *imageID)
}
}

logging.Logger.Infof("[OK] %d AMI(s) terminated in %s", len(imageIds), *session.Config.Region)
logging.Logger.Infof("[OK] %d AMI(s) terminated in %s", deletedCount, *session.Config.Region)
return nil
}

0 comments on commit 37e1170

Please sign in to comment.