terraform - 如何在外部数据查询中使用模块输出变量
问题描述
我正在使用 terraform 模块在 Azure 中创建专用终结点。创建私有端点后,我需要通过调用 API 创建 DNS 条目。所以我正在使用 ```data external`` 资源执行一个 python 脚本。python 脚本的输入之一是私有端点 IP。我试图通过查询使用来自私有端点模块的输出变量(private_endpoint_ip)作为python脚本的输入。这是我的代码
module "pe" {
source = "../../
private_endpoint_network = {resource_group_name = "test", vnet_name = "test", subnet_name = "test"}
private_endpoint_name = "test"
private_endpoint_resource_group_name = "test"
location = "eastus"
private_endpoint_resource_id = var.storage_id
subresource_names = ["blob"]
}
data "external" "record" {
depends_on = [module.pe]
program = ["python", "${path.root}/dns.py"]
query = {
name = "abctest"
ipv4 = module.pe.private_endpoint_ip #This is one of the output variables of pe
}
}
如果我在代码上方执行 terraform plan,则会收到以下错误
Error: Incorrect attribute value type
│
│ on main.tf line 40, in data "external" "record":
│ 40: query = {
│ 41: name = "abctest"
│ 42: ipv4 = module.pe.private_endpoint_ip
│ 43: type = "dns"
│ 44: }
│ ├────────────────
│ │ module.pe.private_endpoint_ip is a list of string, known only after apply
│
│ Inappropriate value for attribute "query": element "ipv4": string required.
谁能帮我弄清楚,如何通过查询将私有端点模块的输出作为输入传递给 python 脚本?
解决方案
推荐阅读
- ios - 如何“取消” AVAudioSession on segue 到另一个视图控制器?
- angular - 电子在预标签内加载html
- javascript - ISSUE: 无法读取未定义的属性“getText”
- vba - 如何将变量设置为在查询中检索到的字段值
- java - 共享偏好无法获取数据
- tla+ - PlusCal:为什么公平算法仍然卡顿?
- javascript - 如何在 node.js 中进行嵌套错误处理
- javascript - 在选项卡更改时隐藏、取消隐藏内容
- ios - 如何为 Flutter 应用注册 Apple App Id Bundle?
- c++ - const 是否允许在这里进行(理论上的)优化?