hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.86k stars 9.2k forks source link

'Multiple configurations present' error when overriding provider roles #11079

Open wandergeek opened 4 years ago

wandergeek commented 4 years ago

Community Note

Terraform Version

Terraform v0.11.14

Affected Resource(s)

provider "aws"

Terraform Configuration Files

settings.tf

terraform {
  required_version = "0.11.14"

  backend "s3" {
    role_arn             = "arn:aws:iam::xxxxx:role/cross_account/sre"
    workspace_key_prefix = "xxxxxx"
    bucket               = "xxxxxx"
    key                  = "xxxxxx.tfstate"
    encrypt              = "true"
    region               = "ap-northeast-1"
  }
}

provider "aws" {
  region  = "ap-northeast-1"
  version = "2.15.0"

  assume_role {
    session_name = "terraform"
    role_arn     = "arn:aws:iam::xxxxxx:role/cross_account/sre"
  }
}

provider "aws" {
  region  = "ap-southeast-1"
  version = "2.15.0"
  alias   = "ap-southeast-1"

  assume_role {
    session_name = "terraform"
    role_arn     = "arn:aws:iam::xxxxxx:role/cross_account/sre"
  }
}

override.tf


terraform {
  required_version = "0.11.14"

  backend "s3" {
    role_arn             = "arn:aws:iam::xxxxx:role/services/terraform_ops"
    workspace_key_prefix = "xxxxxx"
    bucket               = "xxxxxx"
    key                  = "xxxxxx.tfstate"
    encrypt              = "true"
    region               = "ap-northeast-1"
  }
}

provider "aws" {
  region  = "ap-northeast-1"
  version = "2.15.0"

  assume_role {
    session_name = "terraform"
    role_arn     = "arn:aws:iam::xxxxxx:role/services/terraform_ops"
  }
}

provider "aws" {
  region  = "ap-southeast-1"
  version = "2.15.0"
  alias   = "ap-southeast-1"

  assume_role {
    session_name = "terraform"
    role_arn     = "arn:aws:iam::xxxxxx:role/services/terraform_ops"
  }
}

The only difference between settings.tf and the override file is the roles have been switched from arn:aws:iam::xxxxxx:role/cross_account/sre to arn:aws:iam::xxxxxx:role/services/terraform_ops.

Debug Output

Full output: https://gist.github.com/wandergeek/09ee3117c12cc47e5a5efef038e026dd

Expected Behavior

I should be able to override the role_arn for aws provider aliases.

Actual Behavior

Error message

Error: provider.aws.ap-southeast-1: multiple configurations present; only one configuration is allowed per provider

Steps to Reproduce

  1. Create settings.tf and override.tf with the contents above.
  2. Run make init

Important Factoids

justinretzolk commented 3 years ago

Hey @wandergeek 👋 Thank you for taking the time to file this issue. Given that there's been a number of Terraform and AWS provider releases since you initially filed it, can you confirm whether you're still experiencing this behavior?

github-actions[bot] commented 3 days ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!