- Newest
- Most votes
- Most comments
Where are your credentials set? Take a look at https://registry.terraform.io/providers/hashicorp/aws/latest/docs/guides/version-4-upgrade#changes-to-authentication
The authentication configuration for the AWS Provider has changed in this version to match the behavior of other AWS products, including the AWS SDK and AWS CLI. This will cause authentication failures in AWS provider configurations where you set a non-empty
profilein theproviderconfiguration but the profile does not correspond to an AWS profile with valid credentials.Precedence for authentication settings is as follows:
providerconfiguration- Environment variables
- Shared credentials and configuration files (e.g.,
~/.aws/credentialsand~/.aws/config)
Are your credentials set using any of these?
A little further down that page:
In other words, when you explicitly set
profileinprovider, the AWS provider will not use environment variables per the precedence shown above. Before v4.0, ifprofilewas configured in theproviderconfiguration but did not correspond to an AWS profile or valid credentials, the provider would attempt to use environment variables. This is no longer the case. An explicitly set profile that does not have valid credentials will cause an authentication error.
The Terraform code that you provided in your question doesn't have a profile in a provider but I'm just wondering if there is any other file where it might be set?
If you are following up above code then you should install AWS CLI and configure your credentials in with profile in ~/.aws/credentials file.
Your credentials are AWS Access key and Secret Access Key. You can create one IAM user and create programming credentials.
As per best practice you should use an IAM role using web identity federation and OpenID Connect (OIDC). This can be configured either using environment variables or in a named profile.
Follow the https://registry.terraform.io/providers/hashicorp/aws/latest/docs for more ways to have AWS credentials.
