title: AWS trouble in Bash Script
body: <p>Consider the AWS CLI commands in a script file</p>
  
  <pre><code>#!/bin/bash
  msgClr='\033[1;35m'
  errClr='\033[1;31m'
  cynClr='\033[1;36m'
  NC='\033[0m'
  #Read CLuster from command Args
  cluster="MyCluster"
  
  #Update Service
  echo -e "${msgClr}Initiate: ${NC}Updating Service..."
  serviceName=$(aws ecs list-services --cluster $cluster | jq '.serviceArns[0]')
  allTaskDefs=$(aws ecs list-task-definitions | jq '.taskDefinitionArns')
  taskDefLength=$(echo $allTaskDefs | jq '. | length')
  latestTaskDefArn=$(echo $allTaskDefs | jq '.['`expr $taskDefLength - 1`']')
  #latestTaskDef=$(echo $latestTaskDefArn | awk 'BEGIN{FS="/"}{print substr($2, 1, length($2)-1)}')
  #echo -e "${msgClr}Using Task Definition: ${cynClr}"$latestTaskDef"${NC}"
  echo "aws ecs update-service --cluster $cluster --task-definition $latestTaskDefArn --service $serviceName" 
  $(aws ecs update-service --cluster $cluster --task-definition $latestTaskDefArn --service $serviceName)
  echo -e "${msgClr}Complete: ${NC}Updating Service..."
  </code></pre>
  
  <p>It fails with </p>
  
  <pre><code>An error occurred (InvalidParameterException) when calling the UpdateService operation: Invalid revision number. Number: aws:ecs:eu-west-1:630026061543:task-definition/ecscompose-production:33"
  </code></pre>
  
  <p>but if I echo out the last command</p>
  
  <pre><code>$(aws ecs update-service --cluster $cluster --task-definition $latestTaskDefArn --service $serviceName)
  </code></pre>
  
  <p>and copy paste it, it runs smoothly. Why and what am I doing wrong?</p>