I'm using the AWS CLI client to get the status of a snapshot but the output is in JSON. eg.
{
"DBClusterSnapshots": [
{
"AvailabilityZones": [
"us-east-2a",
"us-east-2b",
"us-east-2c"
],
"DBClusterSnapshotIdentifier": "...",
"DBClusterIdentifier": "...",
"SnapshotCreateTime": "2021-12-23T05:59:41.658000+00:00",
"Engine": "aurora",
"AllocatedStorage": 517,
"Status": "copying",
"Port": 0,
"ClusterCreateTime": "2020-01-17T18:59:19.045000+00:00",
"MasterUsername": "...",
"EngineVersion": "5.6.mysql_aurora.1.22.1",
"LicenseModel": "aurora",
"SnapshotType": "manual",
"PercentProgress": 0,
"StorageEncrypted": true,
"KmsKeyId": "...",
"DBClusterSnapshotArn": "...",
"SourceDBClusterSnapshotArn": "...",
"IAMDatabaseAuthenticationEnabled": false,
"TagList": []
}
]
}
I can use a combination of grep
and sed
(| grep Status | sed 's/.*"Status": "//' | sed 's/",//'
) to isolate the status of "copying" BUT I was wondering if there was an easier way to parse the JSON in bash. eg. var['DBClusterSnapshots'][0]['Status']