Terraform-provider-aws: provider.aws: NoCredentialProviders: no valid providers in chain. Deprecated

Created on 1 Jul 2018  ·  3Comments  ·  Source: hashicorp/terraform-provider-aws

When moving my credential to %USERPROFILE%\.aws\credentials terraform don't use them and finish with this error message : provider.aws: NoCredentialProviders: no valid providers in chain. Deprecated.

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.7
provider.aws v1.25.0

Affected Resource(s)

Terraform Configuration Files

example.tf

resource "aws_instance" "example" {
  ami           = "ami-2757f631"
  instance_type = "t2.micro"
}

variables.tf

provider "aws" {
  region  = "${var.region}"
  profile = "${var.profile}"   
}

variable "region" {
  description = "Target region"
  default = "us-east-1"
}

variable "profile" {
    description = "The profile you want to use"
    default     = "default"
}

%USERPROFILE%\.aws\credentials

[default]
access_key=********
secret_key=********

Debug Output


I create a gist :
https://gist.github.com/michaelcourcy/dabd8e6f23e47fc51ae3884655e72c9f
The important part is this one

2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe: 2018/07/01 15:44:06 [INFO] AWS Auth using Profile: "default"
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe: 2018/07/01 15:44:06 [INFO] Initializing DeviceFarm SDK connection
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe: 2018/07/01 15:44:06 [DEBUG] [aws-sdk-go] DEBUG: Request ec2metadata/GetMetadata Details:
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe: ---[ REQUEST POST-SIGN ]-----------------------------
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe: GET /latest/meta-data/iam/security-credentials HTTP/1.1
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe: Host: 169.254.169.254
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe: User-Agent: aws-sdk-go/1.14.14 (go1.9.2; windows; amd64)
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe: Accept-Encoding: gzip
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe:
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe:
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe: -----------------------------------------------------
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe: 2018/07/01 15:44:06 [DEBUG] [aws-sdk-go] DEBUG: Send Request ec2metadata/GetMetadata failed, n
ot retrying, error RequestError: send request failed
2018-07-01T15:44:06.814+0200 [DEBUG] plugin.terraform-provider-aws_v1.25.0_x4.exe: caused by: Get http://169.254.169.254/latest/meta-data/iam/security-credentials: dial tcp 169.
254.169.254:80: connectex: Une opération a été tentée sur un réseau impossible à atteindre.

Panic Output

Expected Behavior

It should behave as when I provided the credentials in the variables.tf

provider "aws" {
  region  = "${var.region}"
  profile = "${var.profile}"   
  access_key=********
  secret_key=********
}

Actual Behavior

I get this error message : provider.aws: NoCredentialProviders: no valid providers in chain. Deprecated

Running the command with debug level I can see he's trying to connect to a server unreachable from my window host http://169.254.169.254/latest/meta-data/iam/security-credentials , this server seems to be the default metadata API endpoint for IAM credential. Thus when Terraform run from an aws node.

So if the key and secret is not provided Terraform seem to switch automatically to the EC2 Role authentication provider method and I just can't see how to force it to use the sharedSecret.

I also try to set the shared_credentials_file in the configuration with not much success.

Steps to Reproduce

terraform plan

Important Factoids

References

provider question waiting-response

Most helpful comment

Hi @michaelcourcy 👋 Sorry you're running into trouble here. This configuration works locally for me when I specify my AWS credentials file with:

[profilename]
aws_access_key_id = AKIA...
aws_secret_access_key = ...

Does adjusting the two field names help your issue? I'm not sure access_key and secret_key are valid names according to the AWS documentation

All 3 comments

Hi @michaelcourcy 👋 Sorry you're running into trouble here. This configuration works locally for me when I specify my AWS credentials file with:

[profilename]
aws_access_key_id = AKIA...
aws_secret_access_key = ...

Does adjusting the two field names help your issue? I'm not sure access_key and secret_key are valid names according to the AWS documentation

Hi @bflad, Thanks a lot ! That solving my problem. I close the issue.

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings