Search code examples
amazon-web-servicesamazon-s3terraform

Error while configuring Terraform S3 Backend


I am configuring S3 backend through terraform for AWS.

terraform {
  backend "s3" {}
}

On providing the values for (S3 backend) bucket name, key & region on running "terraform init" command, getting following error

"Error configuring the backend "s3": No valid credential sources found for AWS Provider. Please see https://terraform.io/docs/providers/aws/index.html for more information on providing credentials for the AWS Provider Please update the configuration in your Terraform files to fix this error then run this command again."

I have declared access & secret keys as variables in providers.tf. While running "terraform init" command it didn't prompt any access key or secret key.

How to resolve this issue?


Solution

  • When running the terraform init you have to add -backend-config options for your credentials (aws keys). So your command should look like:

    terraform init -backend-config="access_key=<your access key>" -backend-config="secret_key=<your secret key>"