KamilK
KamilK

Reputation: 329

How to describe tags for rds snapshots

is there any possibility to describe tags for rds snapshots?

for ec2 instances I using:

aws ec2 describe-instances --filters Name=tag:Name,Values= --query 'Reservations[*].Instances[*].{InstanceId:InstanceId}'

but for rds snapshots I can not find any properly command.

Upvotes: 0

Views: 4213

Answers (2)

Matt Houser
Matt Houser

Reputation: 36123

Unfortunately, tags are not included in the snapshot data as part of the rds:DescribeDbSnapshots API command. Instead, you would use the rds:ListTagsForResource API command. As part of the command, you would specify the ARN of the snapshot you are interested in.

Using the AWS CLI, that would look like this:

aws rds list-tags-for-resource \
  --region us-east-1 \
  --resource-name arn:aws:rds:us-east-1:<account>:snapshot:rds:<snapshot-id>

Reference: http://docs.aws.amazon.com/cli/latest/reference/rds/list-tags-for-resource.html

Update after comments

Since describe-db-snapshots does not support filtering, you cannot filter the results based on tags. Instead, you must do the following:

  1. Use describe-db-snapshots to get a complete list of snapshots.
  2. For each snapshot returned, use list-tags-for-resource to get the tags. You can use the --query parameter to limit the results of the tags.
  3. Conditionally, based on the results from list-tags-for-resource include or exclude your snapshot from your list of snapshots you care about.

Upvotes: 3

hjpotter92
hjpotter92

Reputation: 80653

If you check the AWS CLI documentation for the RDS command, you'll notice (in section for describe-db-snapshots subcommand):

--filters (list)

This parameter is not currently supported.

You'll be able to pipe the output without filters to a custom script, and filter there.

Upvotes: 0

Related Questions