What is your account id? I often need to query the list-tags-for-resource using the AWS Command Line Interface (CLI) to retrieve all the tags related to a specific RDS instance.
Looking at how to construct an RDS Amazon Resource Name (ARN) there is apparently no simple way to retrieve only snapshot with a specific tag without relying on external information:
all the information available at “aws rds” CLI level but the account number. Note that you do not have a single API call as for EC2 to retrieve the tags of a snapshot as the –filters option is not supported in the describe-db-snapshots endpoint. Of course there are a few possible workarounds:
- you can write the account id in the script but it’s less than ideal and elegant, almost all if you run multiple AWS accounts and you want to reuse my precious script
- you can the (very unrelated) response of a SQS (or other components) to retrieve the account id from a URL for example:
Name: test-queue URL: https://sqs.us-east-1.amazonaws.com/<account number>/test-queue ARN: arn:aws:sqs:us-east-1:<account number>:test-queue
- In a similar way you can retrieve the account number from the EC2 default security group:
aws ec2 describe-security-groups --group-name default --query 'SecurityGroups.[OwnerId]' --output text
But all these are more hacks than proper implementations. Any better approach to retrieve only manual snapshots with a specific tags using the AWS CLI?