Nested Hash AWS API Call

I am trying to make a call and retrieve meaningful data via the
“describe_instance” method within the Ruby AWS SDK. I’m pretty new to
ruby and it seems I’m missing something fundamental about nested
hashes…anyway…

Here is the doc I’m using as reference http://amzn.to/1baKQ2h

Here is how I set things up (I changed all the data):

aws_instance = @ec2.client.describe_instances(:instance_ids =>
[‘i-gggggg’])
aws_instance.describe_instance

for example, I would like to retrieve the “availability_zone” which
appears to be nested (in the documentation) within the “placement” hash
which is in the “instances” set.

Can someone form a sample call that I could use as a reference?

From:
http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/Core/Response.html

I can guess …

response = @ec2.client.describe_instances(:instance_ids => [‘i-gggggg’])

instance = response.data[:reservation_set].first[:instance_set].first

availability_zone = instance[:placement][:availability_zone]

Note 1: When it says “Array” it’s an Array of Hashes. So, if I call
“first” on it, I have a Hash in return and I can call [] on it.
Note 2: I have no means to test this. Just let me know if it works.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs