I am using below code to for configuring aws creds.
provider "aws" {
region = var.region_name
profile = "default"
}
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.76"
}
}
required_version = ">= 0.14.9"
}
I was getting below error whenever we run terraform plan
Error:
Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found.
│
│ Please see https://registry.terraform.io/providers/hashicorp/aws
│ for more information about providing credentials.
│
│ Error: NoCredentialProviders: no valid providers in chain
│ caused by: EnvAccessKeyNotFound: failed to find credentials in the environment.
│ SharedCredsLoad: failed to load profile, default.
│ EC2RoleRequestError: no EC2 instance role found
│ caused by: RequestError: send request failed
│ caused by: Get "http://169.254.169.254/latest/meta-data/iam/security-credentials/": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
I tried upgrading my aws provider version as per https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/version-4-upgrade#changes-to-authentication and it started working as below:
provider "aws" {
region = var.region_name
profile = "default"
}
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
required_version = ">= 0.14.9"
}