devopshobbies / terraform-tutorial

you can follow up this repo to learn terraform with practical examples. also we recommend to check our youtube channel for this topic.
GNU General Public License v3.0
64 stars 25 forks source link

[Help wanted]: error configuring S3 Backend: #28

Open masoudkavehie opened 1 year ago

masoudkavehie commented 1 year ago

Before anything

What is the problem?

When I was trying to run terraform init after ive added backend s3 on my provider file i got this error .why it happend for me .

Logs (optional).

Initializing the backend...
╷
│ Error: error configuring S3 Backend: no valid credential sources for S3 Backend found.
│ 
│ Please see https://www.terraform.io/docs/language/settings/backends/s3.html
│ for more information about providing credentials.
│ 
│ Error: NoCredentialProviders: no valid providers in chain. Deprecated.
│   For verbose messaging see aws.Config.CredentialsChainVerboseErrors
│
Imany-apk commented 1 year ago

To use your IAM credentials to authenticate the Terraform AWS provider, you should set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables of your own.

Did you set them?

masoudkavehie commented 1 year ago

yes i did it

Shayan-Ghani commented 1 year ago

I assume you're using Localstack. In this case, you won't need s3 as localstack, as the name implies, is for testing in the local environment. However, you can create a module and add the terraform block to its provider.tf file. This solves this error but is not best practice and you'll get a warning. you can check out a repository of mine in which I have done the exact thing. it might help you.