dtan4 / terraforming

Export existing AWS resources to Terraform style (tf, tfstate) / No longer actively maintained
http://terraforming.dtan4.net/
MIT License
4.3k stars 657 forks source link

Terraforming ec2 throws error for missing volumes #499

Open myoung34 opened 4 years ago

myoung34 commented 4 years ago

If instances are terminated, their volumes dont exist.

terraforming ec2 in this state can result in an error

$ aws-vault exec work -- terraforming ec2 --no-tfstate
Enter passphrase to unlock /home/myoung/.awsvault/keys/:
Traceback (most recent call last):
        26: from /home/myoung/.asdf/installs/ruby/2.6.5/bin/terraforming:23:in `<main>'
        25: from /home/myoung/.asdf/installs/ruby/2.6.5/bin/terraforming:23:in `load'
        24: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/terraforming-0.18.0/bin/terraforming:5:in `<top (required)>'
        23: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/base.rb:485:in `start'
        22: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
        21: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
        20: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
        19: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:50:in `ec2'
        18: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:250:in `execute'
        17: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/terraforming-0.18.0/lib/terraforming/cli.rb:263:in `tf'
        16: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/terraforming-0.18.0/lib/terraforming/resource/ec2.rb:7:in `tf'
        15: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/terraforming-0.18.0/lib/terraforming/resource/ec2.rb:19:in `tf'
        14: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/terraforming-0.18.0/lib/terraforming/util.rb:4:in `apply_template'
        13: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/2.6.0/erb.rb:901:in `result'
        12: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/2.6.0/erb.rb:901:in `eval'
        11: from (erb):1:in `apply_template'
        10: from (erb):1:in `each'                                                                                                                                 9: from (erb):24:in `block in apply_template'
         8: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/terraforming-0.18.0/lib/terraforming/resource/ec2.rb:76:in `block_devices_of'
         7: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/aws-sdk-ec2-1.148.0/lib/aws-sdk-ec2/client.rb:23123:in `describe_volumes'
         6: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.90.1/lib/seahorse/client/request.rb:70:in `send_request'
         5: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.90.1/lib/seahorse/client/plugins/response_target.rb:23:in
`call'
         4: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.90.1/lib/aws-sdk-core/plugins/response_paging.rb:10:in `ca
ll'
         3: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.90.1/lib/aws-sdk-core/plugins/param_converter.rb:24:in `ca
ll'
         2: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.90.1/lib/aws-sdk-core/plugins/idempotency_token.rb:17:in `
call'
         1: from /home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.90.1/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:20:in
 `call'
/home/myoung/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/aws-sdk-core-3.90.1/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call': The
 volume 'vol-04882e4bfae7ad9f1' does not exist. (Aws::EC2::Errors::InvalidVolumeNotFound)

easiest would be to not try to work on instances that are terminated (this code exists), but also Terminating (the act of being terminated)

vadirajks commented 4 years ago

is there any way to skip this error. Please help us. Thanks