title: Terraform not using provided AWS profile?
body: <p>I'll update later, but for now...</p>
  <pre><code>$ terraform --version
  Terraform v0.12.17
  + provider.aws v3.23.0
  </code></pre>
  <p>I have an AWS profile set in my <code>./aws/credentials</code> and <code>~/.aws/config</code> files, like so...</p>
  <pre><code>~/.aws/credentials
  [default]
  aws_access_key_id=****
  aws_secret_access_key=****
  
  [myprofile]
  aws_access_key_id=****
  aws_secret_access_key=****
  
  ~/.aws/config
  [default]
  region=us-east-1
  output=json
  
  [profile myprofile]
  region=us-east-1
  output=json
  </code></pre>
  <p>In my Terraform plan, I have</p>
  <pre><code>provider &quot;aws&quot; {
    region  = &quot;us-east-1&quot;
    profile = &quot;myprofile&quot;
  }
  
  terraform {
    required_version = &quot;&gt;= 0.12.17, &lt; 0.13&quot;
  }
  
  resource &quot;aws_vpc&quot; &quot;vpc&quot; {
    cidr_block = &quot;10.123.123.0/24&quot;
  
    tags = {
      Name = &quot;test_vpc&quot;
    }
  }
  
  output &quot;vpc_id&quot; {
    value = aws_vpc.vpc.id
  }
  </code></pre>
  <p>And I have a plan that creates a VPC, so I do</p>
  <pre><code>$ export AWS_PROFILE=myprofile
  $ terraform apply
  Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
  
  Outputs:
  
  module_vpc_id = vpc-123456abced
  </code></pre>
  <p>As you can see the plan creates the VPC, however, the VPC doesn't get created in the <code>myprofile</code> account but in the <code>default</code> account. I know so because 1) I don't see it in the <code>myprofile</code> account, and 2) when I destroy the plan, it shows the <code>owner_id</code> as the <code>default</code> account number. Why?</p>
  <p><strong>Update:</strong> Note if I add the <code>access_key</code> and <code>secret_key</code> key/value pairs in my <code>provider {}</code> block, it creates the VPC in the correct account. Of course I don't wanna do this, but just wanted to prove that the script indeed works with the <code>myprofile</code> account.</p>
  <p><strong>Update:</strong> Note the following commands return nothing (blanks)</p>
  <pre><code>$ echo $AWS_ACCESS_KEY_ID
  $ echo $AWS_SECRET_ACCESS_KEY
  </code></pre>
  <p>and running <code>env</code> doesn't show those variables.</p>