Wait until a condition is met in bash script
adding an if else until helped me get out of the loop.
until [ $(aws ssm get-automation-execution --automation-execution-id "$id" --query 'AutomationExecution.AutomationExecutionStatus' --output text) = *"InProgress"* ];
do
echo "Automation is running......"
sleep 10s
if [ $(aws ssm get-automation-execution --automation-execution-id "$id" --query 'AutomationExecution.AutomationExecutionStatus' --output text) != "InProgress" ]; then
echo "Automation Finished"
status=$(aws ssm get-automation-execution --automation-execution-id "$id" --query 'AutomationExecution.AutomationExecutionStatus' --output text)
echo "Automation $status"
if [$status != "Success"]; then
exit 3
echo "Automation $status"
fi
break
fi
done