#!/bin/bashset -ue# use AWS CLI to launch a clustercreate_cluster_response=$(aws emr create-cluster \  --release-label emr-4.3.0 \  --region us-east-1 \  --etc) # many more arguments; see http://docs.aws.amazon.com/cli/latest/reference/emr/create-cluster.html# use jq to parse and display resultcluster_id=$(echo ${create_cluster_response} | jq -r '.ClusterId')echo ClusterId=${cluster_id}echo AWS Management Console URL: https://console.aws.amazon.com/elasticmapreduce/home?region=us-east-1#cluster-details:${cluster_id}# block until the EMR cluster terminatesprevious_state=''while true; do  json=$(aws emr describe-cluster --cluster-id ${cluster_id}) # see http://docs.aws.amazon.com/cli/latest/reference/emr/describe-cluster.html  state=$(echo ${json} | jq -r '.Cluster.Status.State')  # echo state changes  if [[ ${state} != ${previous_state} ]]; then    now=$(date -u +%Y-%m-%dT%H:%M:%SZ) # format date as ISO 8601 UTC    message=$(echo ${json} | jq -r '.Cluster.Status.StateChangeReason.Message')    echo ${now} ${state} ${message}    previous_state=${state}  fi  # terminate this script when the cluster terminates  if [[ ${state} == TERMINATED ]]; then    echo EMR JOB SUCCESS    exit 0  fi  if [[ ${state} == TERMINATED_WITH_ERRORS ]]; then    echo EMR JOB FAILURE    exit 1  fi  sleep 10doneI am very new to programming bash and will appreciate any and all feedback.
A bash script to submit an AWS EMR job and poll until the cluster terminates
bash;amazon web services