I am trying to create an AWS S3 bucket using terraform and this is my code:
provider "aws" {
profile = "default"
region = "ap-south-1"
}
resource "aws_s3_bucket" "first_tf" {
bucket = "svk-pl-2909202022"
acl = "private"
}
I have manually created the "Credentials" file using Notepad and also removed the ".txt" extension using Powershell and stored that file in C:\Users\terraform\.aws
, and that file is like this:
[default]
aws_access_key_id=**************
aws_secret_access_key=************
But when I try to run terraform plan
, I get an error which says
ERROR: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found
Then, I also tried to create that "Credentials" file by installing AWS CLI, I ran the command
aws configure --profile terraform
where terraform
was my username. So, it asked me to enter aws_access_key_id
and aws_secret_access_key
. and after entering all the credentials, I ran the command terraform init
, which ran successfully but when I ran terraform plan
, it shows the error again which says:
ERROR: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found
When you create a profile manually
When you don't want to put your shared file manually
That needs to be in this path
%USERPROFILE%.aws\credentials
If you want to put your credentials in a tf file