I use terrafrom to build aws resource and it work fined before,but today I suddenly got a error “error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found.” when run the terraform plan commend, and the full error is ╷
│ Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found.
│
│ Please see Terraform Registry
│ for more information about providing credentials.
│
│ Error: no EC2 IMDS role found, operation error ec2imds: GetMetadata, request send failed, Get “http://169.254.169.254/latest/meta-data/iam/security-credentials/”: dial tcp 169.254.169.254:80: connectex: A socket operation was attem
pted to an unreachable network.
│
│
│ with provider[“Terraform Registry”],
│ on main.tf line 5, in provider “aws”:
│ 5: provider “aws” {
│
╵
my provider config is:
terraform {
required_version = “>=0.12”
}
I’m having the exact same issue. Earlier terraform plan used to work fine, looks like this has something to do with new aws provider version 4.1
Did you manage to find the resolution ?
I faced the same error while launching my first instance on aws, I just added access_key and secret_key in the provider section and my error solved after terraform plan.
provider “aws” {
region = “us-east-2” #new line added here
access_key = “######”
secret_key = “######”