AWS SDK for Ruby
Developer Guide

Getting Information about a Specific Amazon EC2 Instance

The following example lists the state of an instance i-123abc in the us-west-2 region.

require 'aws-sdk-ec2' # v2: require 'aws-sdk' ec2 = Aws::EC2::Resource.new(region: 'us-west-2') i = ec2.instance('i-123abc') if i.exists? puts "State: #{i.state.name}" end