Terraform S3 Backend – Fix Authentication with Shared Credentials File

terraform

I have my credentials in my ~/.aws/credentials file and I can use aws cli perfectly fine but when I do a terraform init I get the following error:

Error initializing new backend: 
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.

By default if i dont specify my credentials on backend.tf it should look in ~/.aws/credentials by default.Not sure what the issue is. i have double checked the access and nohing has changed.

Terraform version: Terraform v0.11.11

My backed.tf looks like this:

terraform {
  backend "s3" {
    bucket = "ms14terraform"
    key    = "path/to/my/key/terraform.tfstate"
    dynamodb_table = "terraform-state-lock-dynamo"
    region = "eu-west-1"
  }
}

this is on my ubuntu machine

Best Answer

seems like this was an issue due to the snap install on ubuntu, direct download from the terraform website seemed to fix the issue: download link