chinta kiran
chinta kiran

Reputation: 129

awscli query ec2 describe-instances

how can I use --query and get only few fields

1.) aws ec2 describe-instances --output json --region us-east-1 2.) aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,State.Name,InstanceType,PrivateIpAddress,PublicIpAddress]' --output json --region us-east-1

The command 1 shows all values but the command 2 should null values. What went wrong in command 2

Upvotes: 1

Views: 1489

Answers (1)

Arora20
Arora20

Reputation: 1063

Corrected the command -

aws ec2 describe-instances --query  'Reservations[*].Instances[*].[InstanceId,State.Name,InstanceType,PrivateIpAddress,PublicIpAddress]' 

You missed the * Due to which you got null values.

Upvotes: 1

Related Questions