patternMinor
List encrypted RDS snapshots using CLI
Viewed 0 times
snapshotsencryptedrdsusingclilist
Problem
I have automated the RDS snapshot copy across the region, but the Snapshot which is encrypted gets fail to copy.
I have figured a way to copy an encrypted snapshot using
I want to filter/test the snapshots if they are encrypted or not, if they are encrypted I will perform the above-defined operation.
I tried this which is not working.
How do I list/filter all the encrypted snapshots and move it to a file?
I have figured a way to copy an encrypted snapshot using
$ aws rds copy-db-snapshot --source-db-snapshot-identifier arn:aws:rds:eu-west-1:XXXX:snapshot:XXX-2017-01-31-04-30 --target-db-snapshot-identifier mydbsnapshotcopy --kms-key-id XXX --region eu-central-1 --source-region eu-west-1I want to filter/test the snapshots if they are encrypted or not, if they are encrypted I will perform the above-defined operation.
I tried this which is not working.
$ aws rds describe-db-snapshots --filter "Name=encrypted,Values=true"How do I list/filter all the encrypted snapshots and move it to a file?
Solution
Either use the
If the
Second way:
One of them should work. Might need a bit messing around as I don't have your output to tune the
--query attributeaws rds describe-db-snapshots --query "DBSnapshots[?Encrypted].DBSnapshotIdentifier"If the
[?Encrypted] does not work, try [?Encrypted == 'true'] as the first is from JMESPath improved filters. The quotes might need to be backticks in some case. It all depends.Second way:
aws rds describe-db-snapshots --output json | jq '.DBSnapshots | map(select(has("Encrypted"))) | .[].DBSnapshotIndetifier'One of them should work. Might need a bit messing around as I don't have your output to tune the
jq command. Feel free to edit and fix the answer.Code Snippets
aws rds describe-db-snapshots --query "DBSnapshots[?Encrypted].DBSnapshotIdentifier"aws rds describe-db-snapshots --output json | jq '.DBSnapshots | map(select(has("Encrypted"))) | .[].DBSnapshotIndetifier'Context
StackExchange DevOps Q#2871, answer score: 3
Revisions (0)
No revisions yet.