<p>If you have multiple profiles in your credentials file, you need to state which profile you want to use, otherwise it will use <code>[default]</code>:</p>
<p>credentials file:</p>
<pre><code>[default]
aws_access_key_id = xxxxxxxx
aws_secret_access_key = xxxxxxxx
[profile2]
aws_access_key_id = yyyyyyyy
aws_secret_access_key = yyyyyyyyy
</code></pre>
<p>terraform code:</p>
<pre><code>provider &quot;aws&quot; {
   region = var.aws_region
   shared_credentials_file = &quot;/Users/samueldare/.aws/credentials&quot;
   profile = &quot;profile2&quot;
}
</code></pre>
<p>As stated in the <a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs#shared-configuration-and-credentials-files" rel="nofollow noreferrer">docs</a></p>

CC BY-SA 4.0
2022-06-03T09:36:03.813Z
2022-06-03T09:36:03.813Z
Darko Petrovic
<p>I am trying to use terraform to spin up a new instance of a server.</p>
<p>Using the AWS provider , I get this error:</p>
<pre class="lang-bash prettyprint-override"><code>╷
│ Warning: Resource targeting is in effect
│ 
│ You are creating a plan with the -target option, which means that the result of this plan may not represent all of the changes requested by the current configuration.
│ 
│ The -target option is not for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an
│ error message.
╵
╷
│ Error: error configuring Terraform AWS Provider: failed to get shared config profile, 2auth
│ 
│   with provider[&quot;registry.terraform.io/hashicorp/aws&quot;],
│   on main.tf line 1, in provider &quot;aws&quot;:
│    1: provider &quot;aws&quot; {
│ 
</code></pre>
<p>first off , I have no idea where this 2auth profile it is referencing is.</p>
<p>Also I have tried setting my credentials with in both the tf file</p>
<pre class="lang-bash prettyprint-override"><code>provider &quot;aws&quot; {
   region = var.aws_region
   shared_credentials_file = &quot;/Users/samueldare/.aws/credentials&quot;
}
</code></pre>
<p>and as environment variables, but it still doesnt work.</p>
<p>I would appreciate pointers as to what I am doing wrong.</p>

CC BY-SA 4.0
2022-05-18T10:13:45.757Z
is it possible that you are using a module which declares a provider inside it, that you are not aware of? Or is there only the root module?
Bruce Becker
<amazon-web-services><terraform>
Unable to authenticate with Terraform AWS provider
0xsegfault
# Unable to authenticate with Terraform AWS provider

(Asked by: username_0 on 2022-05-18)

I am trying to use terraform to spin up a new instance of a server.
Using the AWS provider , I get this error:
╷
│ Warning: Resource targeting is in effect
│ 
│ You are creating a plan with the -target option, which means that the result of this plan may not represent all of the changes requested by the current configuration.
│ 
│ The -target option is not for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when Terraform specifically suggests to use it as part of an
│ error message.
╵
╷
│ Error: error configuring Terraform AWS Provider: failed to get shared config profile, 2auth
│ 
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on main.tf line 1, in provider "aws":
│    1: provider "aws" {
│ 

first off , I have no idea where this 2auth profile it is referencing is.
Also I have tried setting my credentials with in both the tf file
provider "aws" {
   region = var.aws_region
   shared_credentials_file = "/Users/samueldare/.aws/credentials"
}

and as environment variables, but it still doesnt work.
I would appreciate pointers as to what I am doing wrong.

**Tags:** amazon-web-services, terraform

> **Comments:**
> **username_1**: is it possible that you are using a module which declares a provider inside it, that you are not aware of? Or is there only the root module?  

---

## 1 answers

### Answer by username_2 on 2022-06-03. Score: 1 | Accepted answer

If you have multiple profiles in your credentials file, you need to state which profile you want to use, otherwise it will use [default]:
credentials file:
[default]
aws_access_key_id = xxxxxxxx
aws_secret_access_key = xxxxxxxx
[profile2]
aws_access_key_id = yyyyyyyy
aws_secret_access_key = yyyyyyyyy

terraform code:
provider "aws" {
   region = var.aws_region
   shared_credentials_file = "/Users/samueldare/.aws/credentials"
   profile = "profile2"
}

As stated in the docs


---

