title: Getting state of EC2 instance Java API
body: <p>I am trying to automate some stuff on AWS and I am using Java API to do this. I am able to launch number of instances I want, but I am unable to find the right class or method that can fetch me the current state of the instance (like running, stopped etc). </p>
  
  <p>I tried this</p>
  
  <p><code>DescribeInstanceStatusRequest describeInstance = new DescribeInstanceStatusRequest().withInstanceIds(instances.get(i).getInstanceId());
  DescribeInstanceStatusResult attr = ec2.describeInstanceStatus(describeInstance);
  List&lt;InstanceStatus&gt; state = attr.getInstanceStatuses();</code></p>
  
  <p>not sure why the instance status is a list</p>
  
  <p>Can someone please point me to right API call.</p>
  
  <p>Thanks in advance</p>