Configuration_aliases within module results in "Variables may not be used here." when alias name is unquoted

Hello,

I am trying to pass aws alias configuration down into a module, where in the module it’s specified like this:

terraform {
  required_version = ">= 0.12"
  
  required_providers {
    pagerduty = {
      source  = "PagerDuty/pagerduty"
      version = "~> 1.9.4"
    }

    aws = {
      source = "hashicorp/aws"
      // Relaxed version constraint to avoid multi-version requirements issues
      version = ">= 2.0.0"
      configuration_aliases = [ aws.platform ]
    }
  }
}

When trying to plan this configuration (with TF-12.x or TF-13.x, doesn’t really matter), I get an error:

Variables may not be used here.

Although the sole Terraform documentation prescribe such usage, see Providers Within Modules - Configuration Language | Terraform | HashiCorp Developer (in the end of the section, right before the next section starts).

Obviously, quoting the value results in provider configuration not been passed properly into the module…

Am I doing something wrong, or is it a bug with the Terraform / AWS Provider?

Thank you!

2 Likes

I am having the same issue here.

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 2.7.0"
      configuration_aliases = [ aws.useast1, aws.useast2 ]
    }
  }
}
1 Like

+1.
I thought i’m fairly resourceful when it comes to terraform, but lately all these new versions popping up every 2 seconds, and the tons of changes are confusing the hell out of me. Not to mention, that you cannot switch to documentation for older versions on the website anymore…

Btw, if you switch to version 0.15, the error disappears. although it didn’t solve my original problem…

1 Like

Installing version 0.15.1 of terraform fixes
BR,
Boran

Also encountering this with 0.13.7.

Is there any sort of solution besides upgrade to 0.15?

1 Like

The configuration_aliases block was introduced in 0.15. For 0.13, see the 0.13 docs, and specifically:

The subdirectory ./tunnel must then contain proxy configuration blocks like the following, to declare that it requires its calling module to pass configurations with these names in its providers argument:

provider "aws" {
  alias = "src"
}

provider "aws" {
  alias = "dst"
}