0

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.

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? Commented May 18, 2022 at 10:13

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.