Advertisement
Guest User

Untitled

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