【问题标题】:share multiple DNS domain with multiple aws accounts by terraform in AWS Resource Access Manager通过 AWS Resource Access Manager 中的 terraform 与多个 aws 账户共享多个 DNS 域
【发布时间】:2021-02-17 05:59:58
【问题描述】:

我正在使用 AWS Route53 解析器将发送到内部域列表(本地)的 DNS 请求转发。通过terraform,我想将我创建的规则分享给公司的其他账户,所以我有以下内容:

# I create as much share endpoint as domain I have, so If I have 30 domains, I'll make 30 endpoint RAM:
resource "aws_ram_resource_share" "endpoint_share" {
  count                     = length(var.forward_domain)
  name                      = "route53-${var.forward_domain[count.index]}-share"
  allow_external_principals = false
}
# Here I share every single endpoint with all the AWS ACcount we have 
resource "aws_ram_principal_association" "endpoint_ram_principal" {
  count              = length(var.resource_share_accounts)
  principal          = var.resource_share_accounts[count.index]

  resource_share_arn = {
    for item in aws_ram_resource_share.endpoint_share[*]:
        item.arn
  }
}

最后一个块,调用第一个块的 arn 输出,它是一个列表。 现在,最后一个块不起作用,我不知道如何使用多个计数,当我运行它时,我收到以下错误:

Error: Invalid 'for' expression

line 37: Key expression is required when building an object.

知道如何进行这项工作吗?

Terraform version: 0.12.23

【问题讨论】:

    标签: amazon-web-services amazon-route53 terraform-provider-aws


    【解决方案1】:

    在 resource_share_arn 中使用方括号,如下所示:

    resource_share_arn = [
      for item in aws_ram_resource_share.endpoint_share[*]:
        item.arn
    ]
    

    【讨论】:

      猜你喜欢
      • 2020-10-11
      • 2021-10-09
      • 2014-04-13
      • 2018-02-15
      • 2015-11-24
      • 2017-07-23
      • 2020-12-04
      • 2020-12-14
      • 1970-01-01
      相关资源
      最近更新 更多