terraform取消for_each中的提供者别名

时间:2020-05-20 00:12:16

标签: terraform

给出多个provider

provider "aws" {
    alias  = "eu-west-1"
    region = "eu-west-1"
} 

provider "aws" { 
    alias  = "ap-northeast-1" 
    region = "ap-northeast-1" 
} 

我有一个实例定义,它将根据该区域加载一个ami。 我想在for_each内设置提供者别名,但我对此表示严重怀疑:

resource "aws_instance" "test" {

  for_each = var.aws_amis
  ami = var.aws_amis[each.key]

  provider = aws.each.key  # <------ THIS LOOKS ODD; terraform init does not complain but probably will fail later...
 }

看起来我做不到……而且必须在每个区域使用显式实例(我在这里仅显示2个,但我想再显示几个)

0 个答案:

没有答案