0

ec2-describe-instance-status always returns all columns specified in documentation

I need a way to know just the state name and state code of the instance of instance.

Is there a way to do so ?

BMW
  • 42,880
  • 12
  • 99
  • 116
Learn More
  • 1,535
  • 4
  • 29
  • 51

2 Answers2

2

These days, it's best to use the [aws-cli][1]:

aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,State.Name,State.Code]' --output text
i-38b3ef47  stopped 80
i-28afe386  stopped 80
i-9da318a2  stopped 80
i-3c5ac651  stopped 80
i-4f45ec91  running 16
i-6d231640  stopped 80
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
1

ec2-describe-instance-status | grep '^INSTANCE\s' | cut -f2,4,5

Nitzan Shaked
  • 13,460
  • 5
  • 45
  • 54
  • I will clarify more. In SQL select you can specify columns. In above command, we are taking all data and using Grep we are merely filtering from complete result. – Learn More Jan 23 '14 at 08:07
  • True. But reading the documentation it doesn't seem like doing what you want is possible, so what I suggest above is a workaround. – Nitzan Shaked Jan 23 '14 at 08:21