The below code is working:
[ec2-user@ip restore]$ echo $snap_name
manual-test-2024-01-11-11-26-19
[ec2-user@ip restore]$ aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating
[ec2-user@ip-10-0-39-226 restore]$
But when trying to get the output as a variable, it is getting an error:
[ec2-user@ip restore]$ snap_count=`aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating`
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
[ec2-user@ip restore]$
Please suggest here.
snap_count=
aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == '$snap_name']' | grep available
Bad value for --query DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == manual-test-creditpoc5-2024-01-11-11:24:50]: Bad jmespath expression: Unknown token '-':
– jayvardhan Jan 11 '24 at 13:41