title: Using AWS CLI from Azure pipeline
body: <p>I'm trying to use AWS cli within a <code>script</code> section of an Azure pipeline. The script section is in a template file and it's accessed from the main pipeline.</p>
  <pre><code>steps:
  - bash: |
      step_function_state=`aws stepfunctions list-executions --state-machine-arn $(stateMachineArn) --status-filter RUNNING |  jq -r '.executions[]|.status' | head -1`
      echo &quot;State machine RUNNING status: ${step_function_state}&quot;
      # Rest of the script#
    displayName: &quot;Test Script&quot;
    env:
      AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
      AWS_DEFAULT_REGION: $(AWS_DEFAULT_REGION)
      AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
  </code></pre>
  <p><code>stateMachineArn</code>, <code>AWS_ACCESS_KEY_ID</code>, <code>AWS_SECRET_ACCESS_KEY</code> and <code>AWS_DEFAULT_REGION</code> are stored in a variable group. When running the pipeline it gives the following error,</p>
  <blockquote>
  <p>An error occurred (UnrecognizedClientException) when calling the ListExecutions operation: The security token included in the request is invalid.</p>
  </blockquote>
  <p>Using the same credentials I am able to run my local CLI and get the results.
  I tried <code>printenv</code> command and all the AWS variables are in the environment too. What could I possibly do wrong?</p>