How to use variable as terraform provider alias?

Viewed 658

I'm using terraform 0.14.8 and my requirement is to set AWS provider alias as a variable. My code block is as follow,

provider "aws" {
    region = var.aws_region
    alias = var.aws_region
}

I'm getting an error as below,

An alias must be a valid name. A name must start with a letter or underscore and may contain only letters, digits, underscore, and dashes.

This is how my variables.tf file looks

    variable "aws_region"{
    default = "eu-west-2"
    }

Any idea on workaround to solve this? I strictly need to use terrafrom version ~>0.14

1 Answers

Its not possible. Alias must be explicitly defined and can't be a variable.

Related