Specify specific columns in ec2-describe-instance-status command

1.5k views Asked by At

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 ?

2

There are 2 answers

0
John Rotenstein On

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
2
Nitzan Shaked On

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