Advertisement
Guest User

Untitled

a guest
Aug 1st, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. instance_id['rows'].each do |row|
  2. instances = row['normal']['tags']
  3. instances.each do |instance|
  4. volume_id_json = `aws ec2 describe-instances --instance-ids #{instance} --output json`
  5. volume_ids = JSON.parse(volume_id_json)
  6. volume_ids['Reservations'][0]['Instances'][0]['BlockDeviceMappings'].map do |volume_id|
  7. volumes = volume_id['Ebs']['VolumeId']
  8. volumes.each do |volume|
  9. description="Snapshot of Instance #{instance} created on #{DATE}"
  10. `aws ec2 create-snapshot --volume-id "#{volume}" --description "#{description}"`
  11. exitstatus = $?.to_i
  12. if exitstatus != 0
  13. puts "Unable to get node names from Chef"
  14. end
  15. end
  16. end
  17. end
  18. end
  19.  
  20. ebs_snapshot_new.rb:21:in `block (3 levels) in <main>': undefined method `each' for "vol-2662ec23":String (NoMethodError)
  21. from ebs_snapshot_new.rb:19:in `map'
  22. from ebs_snapshot_new.rb:19:in `block (2 levels) in <main>'
  23. from ebs_snapshot_new.rb:16:in `each'
  24. from ebs_snapshot_new.rb:16:in `block in <main>'
  25. from ebs_snapshot_new.rb:14:in `each'
  26. from ebs_snapshot_new.rb:14:in `<main>'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement