Skip to content

Terraform S3 Backend does not recognize multiple AWS credentials  #18774

@KevinKirkpatrick

Description

@KevinKirkpatrick

I've trying to store terraform state in an S3 bucket in a non default AWS account. When initializing the terraform S3 backend I get an access denied error. I enabled debugging on an found that terraform s3 backend was using the default account in my shared aws credentials file. The terraform backend should really honor what I'm defining in my aws provider profile.

terraform_version 0.11.8

provider "aws" { region = "us-east-1" profile = "non-default aws account" }

terraform { backend "s3" { bucket = "TF-S3-Bucket" key = "folder/statefile" } }

terraform init
Initializing modules...

  • module.mine

Initializing the backend...
Error inspecting states in the "s3" backend:
AccessDenied: Access Denied
status code: 403, request id: 37C678457C37B5FD, host id: +zQJP6lg11NEvpMPkqNNy3AAgb8rxOs+G2Jf+RpT405CUABwEkeN2xi4Se0t2v1H8E7OPjLSCFk=

~/.aws/credentials
[default]
aws_access_key_id = xxxx
aws_secret_access_key = xxxxxx

[non-default aws account]
aws_access_key_id = xxxx
aws_secret_access_key = xxxxxx

Relates to #13589

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions