lserman / capistrano-elbas

Deploy Rails apps to AWS AutoScale groups
MIT License
96 stars 67 forks source link

Check existence of ami before deleting #19

Closed dpnsan closed 5 years ago

dpnsan commented 7 years ago

I was getting "AWS::Core::Resource::NotFound: unable to find the image" when deleting the old AMI. This change only deletes the AMI if it exists.

"ELBAS: Creating EC2 AMI from EC2 Instance: i-xxxxxxxxx"
"ELBAS: Created AMI: ami-xxxxxxx"
"ELBAS: Creating an EC2 Launch Configuration for AMI: ami-xxxxxxxxxx"
"ELBAS: Created Launch Configuration: ELBAS-xxxxx"
"ELBAS: Attaching Launch Configuration to AutoScale Group"
"ELBAS: Deleting old launch configuration: ELBAS-xxxxxx"
"ELBAS: Deleting old AMI: ami-xxxxxx"
cap aborted!
AWS::Core::Resource::NotFound: unable to find the image
/Users/dave/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/resource.rb:238:in `rescue in block in define_attribute_getter'
/Users/dave/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-v1-1.66.0/lib/aws/core/resource.rb:234:in `block in define_attribute_getter'
/Users/dave/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-v1-1.66.0/lib/aws/ec2/image.rb:172:in `block_device_mappings'
/Users/dave/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/elbas-0.26.0/lib/elbas/ami.rb:43:in `delete_snapshots_attached_to'
/Users/dave/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/elbas-0.26.0/lib/elbas/ami.rb:27:in `block in destroy'
/Users/dave/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/elbas-0.26.0/lib/elbas/ami.rb:24:in `each'
/Users/dave/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/elbas-0.26.0/lib/elbas/ami.rb:24:in `destroy'
/Users/dave/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/elbas-0.26.0/lib/elbas/aws_resource.rb:14:in `cleanup'
/Users/dave/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/elbas-0.26.0/lib/elbas/ami.rb:7:in `create'
lserman commented 5 years ago

I'm just now coming back to maintain this repository using the new AWS SDK and AWS launch templates. I will not be maintaining the old ELBAS that relied on launch configurations and AWS SDK v1. I would welcome the change if the conflicts were resolved and the changes were ported to SDK v3. I've tracked this in #34 if you're interested, but as this is a very old PR I'm going to close for now.