Quoting the AWS documentation
"Note that you can't delete a snapshot of the root device of an EBS volume used by a registered AMI. You must first deregister the AMI before you can delete the snapshot. For more information, see Deregistering Your AMI."
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-deleting-snapshot.html
If there are snapshots from failed builds I think it's a bug. Please file an issue.
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/86be55ae-82aa-401a-8390-3a86b476b873%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
previousSnapshotId=$(aws ec2 describe-images --region ${REGION} --owners self --filters "Name=tag:type,Values=${image_type}" "Name=tag:product_version,Values=${product_version}" --query 'Images[0].{Id:BlockDeviceMappings[0].Ebs.SnapshotId}' | jq .Id -r)
packer build -var "source_ami=${latestCentOS}" -var "region=${REGION}" -var-file=variables.json ami-centos-with-product.json if [ "$?" = "0" ] && [ "$previousSnapshotId" != "null" ]; then echo "Deleting previous AMI snapshot. Id: ${previousSnapshotId}" aws ec2 delete-snapshot --region ${REGION} --snapshot-id ${previousSnapshotId} fi