-
Notifications
You must be signed in to change notification settings - Fork 10.3k
S3 Backend doesn't pick up role from profiles #19482
Copy link
Copy link
Closed
Description
Terraform Version
Terraform v0.11.10
+ provider.aws v1.48.0
+ provider.github v1.3.0
Terraform Configuration Files
Non-working example:
terraform {
backend "s3" {
bucket = "xxx"
key = "projects/xxx.tfstate"
region = "ap-southeast-2"
dynamodb_table = "terraform_locks"
kms_key_id = "arn:aws:kms:ap-southeast-2:xxx:key/xxx"
profile = "default"
}
}Working example:
terraform {
backend "s3" {
bucket = "xxx"
key = "projects/xxx.tfstate"
region = "ap-southeast-2"
dynamodb_table = "terraform_locks"
kms_key_id = "arn:aws:kms:ap-southeast-2:xxx:key/xxx"
profile = "default"
shared_credentials_file = "$HOME/.aws/credentials"
}
}Debug Output
Crash Output
Expected Behavior
I should be able to omit shared_credentials_file and terraform should pick up the role configuration from $HOME/.aws/config.
Actual Behavior
Authentication fails.
Steps to Reproduce
terraform init
Additional Context
-
The documentation and actual source code seem to be unaligned. From the documentation:
shared_credentials_file - (Optional) This is the path to the shared credentials file. If this is not set and a profile is specified, ~/.aws/credentials will be used.
but the actual source code doesn't have that default: https://github.com/hashicorp/terraform/blob/master/backend/remote-state/s3/backend.go#L111-L115
References
- S3 Remote State and Credentials in non-default profiles #13589 – Possibly related but closed for comments.
Reactions are currently unavailable