Error trying to get command status with aws cli

Solution for Error trying to get command status with aws cli
is Given Below:

[*]

I seem to keep getting an error whenever I try to use bash to automate getting the status of a job.
My current bash script currently looks like this:

#!/bin/bash

aws ec2 start-instances --instance-ids=$1; 
start=$(aws ec2 describe-instance-status --instance-id $1)
status=$(echo $start | jq '.InstanceStatuses[0].InstanceState.Name')

#wait for ec2 instance to start running before launching command
while [ "$status" != ""running"" ]
do
  start=$(aws ec2 describe-instance-status --instance-id $1)
  status=$(echo $star | jq '.InstanceStatueses[0].InstanceState.Name')
done


sh_command_id=$(aws ssm send-command --instance-ids=$1 --document-name "AWS-RunShellScript" --parameters 'commands=["echo Helloworld","sleep 60"]');
command_id=$(echo $sh_command_id | jq '.Command.CommandId')

full_status=$(aws ssm list-commands --command-id $command_id)


echo $command_id;
 

aws ec2 stop-instances --instance-ids=$1;

When the script gets to aws ssm list-commands --command-id $command_id I get this error.

An error occurred (ValidationException) when calling the ListCommands operation: 2 
validation errors detected: Value '"67fb9aed-00bf-4741-ae1a-736ddbfba498"' at 'commandId' 
failed to satisfy constraint: Member must satisfy regular expression pattern: ^[A-Fa-
f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}$.; Value 
'"67fb9aed-00bf-4741-ae1a-736ddbfba498"' at 'commandId' failed to satisfy constraint: 
Member must have length less than or equal to 36.

When running everything individually in terminal I get the same error. However, I do not get an error when I mannually type in the commandId as so: full_status=$(aws ssm list-commands --command-id 67fb9aed-00bf-4741-ae1a-736ddbfba498).

Is there some aws formatting I am missing here?

[*]

You might be able to avoid the use of jq by using the aws cli built in --query 'your.json.query' to specify your JSON query and then the --output text to return plain text. It has been a while since I checked so your mileage may vary.

I was able to verify that the following works for checking an ec2 is running:

check_instance() {
    local instance_id="${1}"
    local status="_"
    while [ "${status}" != "running" ] ; do 
        status=$(aws ec2 describe-instance-status 
            --instance-ids ${instance_id} 
            --query "InstanceStatuses[*].InstanceState.Name" 
            --output text)
    done

    echo "${instance_id} is running"
}