简体   繁体   中英

aws-cli only return certain fields

Given this example of aws-cli command

aws rds describe-db-cluster-snapshots

I returns a list of objects with fields.

I only want to display the fields: "SnapshotCreateTime" and "DBClusterIdentifier"

How do I do this?

AWS CLI provides built-in output filtering capabilities with the --query option.

aws rds describe-db-cluster-snapshots --query 'DBClusterSnapshots[*].[SnapshotCreateTime,DBClusterIdentifier]' 

The above will work if your AWS CLI configured in the same region and have single AWS CLI profile. If AWS CLI configured in a different region and different profile then you can use below command.

 aws rds describe-db-cluster-snapshots --query 'DBClusterSnapshots[*].[SnapshotCreateTime,DBClusterIdentifier]' --region us-west-2 --profile test 

cli-usage-output

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM