Skip to content

Terraform S3/Backend ignoring profile parameter #22103

@marcotesch

Description

@marcotesch

Hi there

We are facing issues with Terraform in a Cross-Account Setup. Our Terraform version is shown below:

terraform version
Terraform v0.12.4

Terraform does not use the provided profile = xxx parameter in the backend configuration and therefore we get an access denied error when executing terraform plan | apply.

terraform {
  required_version = ">= 0.12"

  required_providers {
    aws = ">= 2.18.0"
  }

  backend "s3" {
    encrypt        = true
    bucket         = "xxxxxxx"
    key            = "terraform.tfstate"
    region         = "eu-central-1"
    dynamodb_table = "xxxxxxx"
    profile        = "xxxxxxx"
  }
}

Debug Output

It just uses the credentials we provide using the AWS Environment variables, but these are not valid for the AWS S3 Bucket and Backend where we configured different credentials which can be seen in the above mentioned backend configuration.

2019/07/17 10:59:31 [INFO] AWS Auth provider used: "EnvProvider"

Crash Output

Leading to this error:

Error: Error loading state: AccessDenied: Access Denied
        status code: 403

Expected Behavior

Terraform should use the configured backend profile for each backend related API call and the Environment/Provider credentials for each Resource/Data related API call.

Actual Behavior

Terraform uses only the Environment Credentials for each API Call, despite it is related to the Backend or resource creation.

Steps to Reproduce

1. awsume aws-profile-xxx
2. terraform init | plan | apply 

Terraform will always use the assumed environment credentials despite a profile is configured for the backend.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions