amazon web services - How to list all volume-ids associated with ec2 instance using ruby aws-sdk? -


i stuck on listing volumes , volume-ids associated ec2 instance. seeking list ebs-optimized volume attached it.

ec2 = aws::ec2.new(  :access_key_id => 'qwertyuiopasd',  :secret_access_key => 'qwertyuiasdfghzxcvbn1234567' )  ec2.instances["i-qwerty1"].block_device_mappings 

it returning root volume's id.

{"/dev/sda1"=><aws::ec2::attachment volume_id:vol-123456 instance_id:i-qwerty1 device:/dev/sda1>} ``` 

is there method can list associated volume-ids.

i tried using ec2 internal meta-data, provided ami volume details

$ curl -l http://169.254.169.254/latest/meta-data/block-device-mapping $ ami 

also instance being managed in chef. checked ohai data instance. can't find list of volumes attached it.

please help!! :)

i have solved it.

we can use

ec2.instances[json.parse(<node>.to_s).automatic.ec2.instance_id].block_device_mappings["/dev/sda1"].volume.id


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -