amazon-web-services - 通过 AWS Resource Access Manager 中的 terraform 与多个 aws 账户共享多个 DNS 域
问题描述
我正在使用 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
解决方案
在 resource_share_arn 中使用方括号,如下所示:
resource_share_arn = [
for item in aws_ram_resource_share.endpoint_share[*]:
item.arn
]
推荐阅读
- javascript - 我怎样才能使这个活跃的点击?
- arduino-ide - 索尼 Spresense 硬故障故障排除
- c# - 列表框。如何增加高度项?
- apache-spark - Parquet 如何处理 SparseVector 列?
- maven - 生成的文件在错误的地方
- sql - 在 m:m 关系中查找第一次出现的字符串
- go - ++ go 中映射键循环的运算符
- css - 如何使用引导程序居中对齐按钮?
- python - 如何将数据框转换为“ColumnName1 | Value1 \r\n ColumnName2 | Value2 \r\n ColumnName3 | Value3”等
- google-cloud-platform - 是否可以使用 Google Cloud Functions 进行蓝绿色部署?