amazon web services - Chef EC2 EBS Volume Using AWS Cookbook InvalidInstanceIDNotFound -


i'm using chef provided aws cookbook (v2.7.2) create , attach ebs volume on ubuntu server 14.04.02 lts hvm ec2 instance during initial bootstrapped chef-client run. i'm hosting own chef server (12.1.0-1_amd64). using knife-ec2, create aws instance , bootstrap runlist via following command:

knife ec2 server create --region us-east-1 --availability-zone us-east-1a --node-name my-server --run-list "role[my-role]" --image ami-d05e75b8 --flavor c3.large --ebs-size 16 --ebs-volume-type gp2 --subnet subnet-mysubnetid --associate-public-ip --server-connect-attribute public_ip_address --ssh-user ubuntu --ssh-key my-pem --identity-file /path/to/my-pem.pem -y 

however, when recipe executes creates , attaches volume, volume creates, fails attach instance. following error keeps occuring:

aws::ec2::errors::invalidinstanceidnotfound: instance id 'i-36a93b84' not exist 

the following code in recipe (taken example on cookbook page):

include_recipe 'aws'  aws_ebs_volume "backup_volume"   aws_access_key aws['aws_access_key_id']   aws_secret_access_key aws['aws_secret_access_key']   size 16   device "/dev/sdi"   availability_zone "us-east-1a"   action [ :create, :attach ] end 

i verified 'i-36a93b84' id of instance knife-ec2 creates , chef-client executing on, exist. also, validated i'm creating volume in same availability zone instance.

i've read posts aws's eventual consistency, have no idea how handle during bootstrapped chef-client run, since recipe runs after instance created.

is there way create additional mount @ time knife-ec2 creates aws server, or trying attach volume in unorthodox manner?

chef client output during recipe:

   recipe: my-cookbook::backupvolume       * aws_ebs_volume[backup_volume] action create[2015-07-17t11:57:05+00:00] info: processing aws_ebs_volume[backup_volume] action create (my-cookbook::backupvolume line 49)       [2015-07-17t11:57:05+00:00] debug: providers generic aws_ebs_volume resource enabled on node include: [lwrp provider aws_ebs_volume cookbook aws]       [2015-07-17t11:57:05+00:00] debug: provider action create on resource aws_ebs_volume[backup_volume] lwrp provider aws_ebs_volume cookbook aws       [2015-07-17t11:57:05+00:00] debug: instance id i-36a93b84       [2015-07-17t11:57:05+00:00] debug: instance's availability zone us-east-1a       [2015-07-17t11:57:05+00:00] debug: created new  volume vol-4842ecc4       [2015-07-17t11:57:05+00:00] debug: volume creating       [2015-07-17t11:57:08+00:00] info: volume vol-4842ecc4 available         - create volume id= size=16 availability_zone=us-east-1a , update node data created volume's id         * aws_ebs_volume[backup_volume] action attach[2015-07-17t11:57:08+00:00] info: processing aws_ebs_volume[backup_volume] action attach (my-cookbook::backupvolume line 49)       [2015-07-17t11:57:08+00:00] debug: providers generic aws_ebs_volume resource enabled on node include: [lwrp provider aws_ebs_volume cookbook aws]       [2015-07-17t11:57:08+00:00] debug: provider action attach on resource aws_ebs_volume[backup_volume] lwrp provider aws_ebs_volume cookbook aws       [2015-07-17t11:57:08+00:00] debug: attaching vol-4842ecc4 /dev/sdi           ================================================================================         error executing action `attach` on resource 'aws_ebs_volume[backup_volume]'         ================================================================================          aws::ec2::errors::invalidinstanceidnotfound         -------------------------------------------         instance id 'i-36a93b84' not exist          cookbook trace:         ---------------         /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:212:in `attach_volume'         /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:70:in `block (2 levels) in class_from_file'         /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:68:in `block in class_from_file'          resource declaration:         ---------------------         # in /var/chef/cache/cookbooks/my-cookbook/recipes/backupvolume.rb           49:       aws_ebs_volume "backup_volume"          50:         aws_access_key aws['aws_access_key_id']          51:         aws_secret_access_key aws['aws_secret_access_key']          52:         size 16          53:         device "/dev/sdi"          54:         description "test backup"          55:         availability_zone "us-east-1a"          56:         action [ :create, :attach ]          57:       end          58:          compiled resource:         ------------------         # declared in /var/chef/cache/cookbooks/my-cookbook/recipes/backupvolume.rb:49:in `from_file'          aws_ebs_volume("backup_volume")           action [:create, :attach]           updated true           retries 0           retry_delay 2           default_guard_interpreter :default           declared_type :aws_ebs_volume           cookbook_name "my-cookbook"           recipe_name "backupvolume"           aws_access_key "********"           aws_secret_access_key "********"           size 16           device "/dev/sdi"           description "test backup"           availability_zone "us-east-1a"           timeout 180           volume_type "standard"           piops 0         end 

here stacktrace:

 aws::ec2::errors::invalidinstanceidnotfound: aws_ebs_volume[backup_volume] (my-cookbook::backupvolume line 49) had error: aws::ec2::errors::invalidinstanceidnotfound: instance id 'i-36a93b84' not exist /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call' /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/seahorse/client/plugins/param_conversion.rb:22:in `call' /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/aws-sdk-core/plugins/response_paging.rb:10:in `call' /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/seahorse/client/plugins/response_target.rb:18:in `call' /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/seahorse/client/request.rb:70:in `send_request' /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/aws-sdk-core-2.0.48/lib/seahorse/client/base.rb:216:in `block (2 levels) in define_operation_methods' /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:212:in `attach_volume' /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:70:in `block (2 levels) in class_from_file' /opt/chef/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `call' /opt/chef/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `add_action' /opt/chef/embedded/apps/chef/lib/chef/provider.rb:175:in `converge_by' /var/chef/cache/cookbooks/aws/providers/ebs_volume.rb:68:in `block in class_from_file' 

the problem due own foolishnes.

the aws credentials in databag old decomissioned aws account aws credentials used create instance w/ knife current aws account.

once correct keys put in databag, volume created , attached!

hope helps in future...


Comments