Problem Initializing terraform with s3 backend - CredentialRequiresARNError

Viewed 1750

I'm having problems initializing terraform s3 backend in following setup. This works well with terraform version 0.11.15 but fails with 0.15.5 and 1.0.7.

There are 2 files:

terraform.tf

provider "aws" {
  region = "eu-west-1"
}

terraform {
  backend "s3" {
  }
}

resource "aws_s3_bucket" "this" {
  bucket = "test-bucket"
  acl    = "private"
}

test-env.tfvars

encrypt = true
dynamodb_table = "terraform-test-backend"
bucket = "terraform-test-backend"
key = "terraform/deployment/test-release.tfstate"
region = "eu-west-1"

When I run terraform init -backend-config=test-env.tfvars using terraform 0.11.15 it works and I can peform terraform apply. Here is the output:

Successfully configured the backend "s3"! Terraform will automatically                                                                                                                                                                        
use this backend unless the backend configuration changes.                                                                                                                                                                                    
                                                                                                                                                                                                                                              
Initializing provider plugins...                                                                                                                                                                                                              
- Checking for available provider plugins on https://releases.hashicorp.com...                                                                                                                                                                
- Downloading plugin for provider "aws" (2.70.0)...                                                                                                                                                                                           
* provider.aws: version = "~> 2.70"

But when I try to use versions 0.15.5 and 1.0.7 I get following error:

Error: error configuring S3 Backend: Error creating AWS session: CredentialRequiresARNError: credential type source_profile requires role_arn, profile default

Any ideas how to fix it ?

1 Answers

A few changes were introduced with respect to the s3 backend and the way terraform checks for credentials in version >0.13. Take a look at the the following GitHub issue or even more specifically this one. In addition its outlined in the Changelog

I believe that the issue you are facing is related to the way your aws profile is set up (check your ~/.aws/config).

Related