Skip to content

How to us aws rds describe-db-cluster-snapshots to display attribute as well without manually providing them yourself

0

Hi,

I am running the command below to show the list of snapshots

aws rds describe-db-cluster-snapshots --snapshot-type manual --query 'DBClusterSnapshots[]."DBClusterSnapshotIdentifier"'

This gives output as below:

[
    "blah01",
    "blah02",
    "blah03",
   "blah04"
]

It's all good but I want it to display the attributes/labels as well to it comes out like below:

[
    "DBClusterSnapshotIdentifier":"blah01",
    "DBClusterSnapshotIdentifier":"blah02",
    "DBClusterSnapshotIdentifier":"blah03",
   "DBClusterSnapshotIdentifier":"blah04"
]

I can simply do aws rds describe-db-cluster-snapshots --snapshot-type manual | grep "DBClusterSnapshotIdentifier" but thought I asked as grep will obviously not work on Windows :( I want to do the similar thing to the describe of database and cluster too and same issue of sort. I know there is an option to type in the attribute but I am trying to avoid doing that as I may want 4-5 attributes which will then be a very long list. For instance if I want to display ALL attrinutes maybe? :(

Any advice much appreciated. Thanks.

1 Answer
0

To display the attributes along with their values for DB cluster snapshots using the AWS CLI, you can modify your query to include the attribute names. Here's how you can achieve this:

  1. To display the DBClusterSnapshotIdentifier with its label:
aws rds describe-db-cluster-snapshots --snapshot-type manual --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier: DBClusterSnapshotIdentifier}'

This will output the results in the format you requested.

  1. If you want to display multiple attributes, you can include them in the query like this:
aws rds describe-db-cluster-snapshots --snapshot-type manual --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier: DBClusterSnapshotIdentifier, SnapshotCreateTime: SnapshotCreateTime, Engine: Engine}'
  1. To display all attributes without manually specifying them, you can use a wildcard in your query:
aws rds describe-db-cluster-snapshots --snapshot-type manual --query 'DBClusterSnapshots[].*'

This will return all attributes for each snapshot. However, note that this might produce a large amount of output.

  1. For a more readable format with all attributes, you can use:
aws rds describe-db-cluster-snapshots --snapshot-type manual

This will display all attributes in a structured JSON format.

These approaches will work similarly for describing databases and clusters as well. You can adjust the command (e.g., describe-db-instances for databases) and modify the query as needed to display the desired attributes.
Sources
Amazon RDS examples using AWS CLI - AWS SDK Code Examples

answered a year ago
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.