Hey folks, I’m hitting a snag while trying to set up Terraform with an S3 backend for AWS. Here’s what I’ve got:
terraform {
backend "s3" {
# Config details go here
}
}
When I run terraform init and provide the bucket name, key, and region, I get this error:
No valid credential sources found for AWS Provider.
I’ve put my access and secret keys in providers.tf as variables, but the init command isn’t asking for them. Any ideas on how to fix this? I’m scratching my head here.
I thought maybe I needed to add the credentials to the backend config, but that didn’t work either. Am I missing something obvious? Thanks for any help!
yo spinninggalaxy, sounds like a pain! have u tried exporting AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables? that usually does the trick for me. also, double-check ur providers.tf file - sometimes the syntax can be tricky. good luck!
hey, interesting issue! did u try setting up aws cli and configuring creds there? maybe check your .aws/credentials file. what’s ur aws region? might be a region thing. curious, what enviroment do u use?
I encountered a similar issue when setting up Terraform with an S3 backend. One often overlooked solution is to use an AWS credentials profile. In your ~/.aws/config file, create a named profile with your desired credentials. Then, set the AWS_PROFILE environment variable to that profile name before running Terraform commands. This approach keeps your credentials secure and separate from your Terraform configuration. Additionally, ensure your IAM user or role has the necessary permissions to access the S3 bucket and perform Terraform operations. If issues persist, double-check your bucket policy and encryption settings.