title: Terraform: Credential error when importing aws resources - error calling sts:GetCallerIdentity: ExpiredToken
body: <p>I have some aws resources that I want to import into my terraform state.</p>
  <p>I have set the aws credentials in <code>~/.aws/credentials</code> file:</p>
  <pre><code>[my-profile]
  aws_access_key_id=&lt;ACCESS_KEY_ID&gt;
  aws_secret_access_key=&lt;SECRET_ACCESS_KEY&gt;
  aws_session_token=&lt;SESSION_TOKEN&gt;
  </code></pre>
  <p><code>terraform init</code> ran successfully, but when I try to import the resources with:</p>
  <pre><code>terraform import -var-file=config/us-west-2/default.tfvars -var-file=variables.tfvars -var-file=../globals.tfvars -var profile=my-profile -var region=us-west-2 -var tfstate_bucket=&lt;MY_TF_BUCKET&gt; -no-color &lt;RESOURCE_NAME&gt; &lt;RESOURCE_ID&gt;
  </code></pre>
  <p>I am getting following error even when my credentials have not expired:</p>
  <pre><code>Error: error using credentials to get account ID: error calling sts:GetCallerIdentity: ExpiredToken: The security token included in the request is expired
      status code: 403, request id: 1684ef71-ecea-4fed-bcf5-a32eca688ab4
  </code></pre>
  <p><strong>Please Note</strong> that I have ran similar imports in another non-production aws account, but I get this error when I try to run it against production account. I do have power-user access to the Production account though.</p>
  <p><strong>Terraform version:</strong></p>
  <pre><code>Terraform v0.12.29
  + provider.aws v3.14.1
  + provider.null v2.1.2
  + provider.random v2.3.1
  + provider.template v2.1.2
  </code></pre>
  <hr />
  <p><strong>EDIT:</strong> Printing environment variables on my mac</p>
  <pre><code>$ env
  TERM_PROGRAM=Apple_Terminal
  TERM=xterm-256color
  SHELL=/bin/bash
  TMPDIR=/var/folders/jz/w997kd9x4sb983kdyj8wjlkc0000gp/T/
  GRADLE_HOME=/Users/john/.sdkman/candidates/gradle/current
  Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.k5lBL3QJ9R/Render
  TERM_PROGRAM_VERSION=421.2
  TERM_SESSION_ID=D2EB66E5-2DD7-456A-8E16-A0E00CE15112
  SDKMAN_PLATFORM=Darwin
  USER=john
  SDKMAN_CANDIDATES_API=https://api.sdkman.io/2
  SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.GG8D8SvuqA/Listeners
  PATH=/Users/john/.sdkman/candidates/gradle/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  PWD=/Users/john/MyProjects/tf/foobar
  LANG=en_US.UTF-8
  SDKMAN_VERSION=5.7.4+362
  XPC_FLAGS=0x0
  XPC_SERVICE_NAME=0
  HOME=/Users/john
  SHLVL=1
  LOGNAME=john
  SDKMAN_DIR=/Users/john/.sdkman
  SDKMAN_CANDIDATES_DIR=/Users/john/.sdkman/candidates
  _=/usr/bin/env
  </code></pre>
  <hr />
  <p><strong>EDIT 2:</strong>
  When I cleaned up all the old profiles and credentials so that <code>~/.aws/credentials</code> and <code>~/.aws/config</code> only has entry for <code>my-profile</code> and nothing else.</p>
  <p>Also all related environment variables:</p>
  <pre><code>for var in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_SECURITY_TOKEN ; do eval unset $var ; done
  </code></pre>
  <p>So now I am getting:</p>
  <pre><code>Error: No valid credential sources found for AWS Provider.
      Please see https://terraform.io/docs/providers/aws/index.html for more information on
      providing credentials for the AWS Provider
  </code></pre>