我定义了一个带有循环的模块:
\nmodule "stamp" {\n for_each = toset(var.stamps)\n source = "./modules/stamp"\n ...\n}\nRun Code Online (Sandbox Code Playgroud)\n由此,我尝试根据以下示例创建一个输出列表:
\noutput "stamp_locations" {\n value = module.stamp.*.location\n}\nRun Code Online (Sandbox Code Playgroud)\n然而,这验证了,但terraform plan我收到错误:
\xe2\x94\x82 Error: Unsupported attribute\n\xe2\x94\x82 \n\xe2\x94\x82 on output.tf line 3, in output "stamp_locations":\n\xe2\x94\x82 3: value = module.stamp.*.location\n\xe2\x94\x82 \n\xe2\x94\x82 This object does not have an attribute named "location"\nRun Code Online (Sandbox Code Playgroud)\n最后只有这个有效:
\noutput "stamp_locations" {\n value = [for instance in module.stamp : instance.location]\n}\nRun Code Online (Sandbox Code Playgroud)\n所以我想知道:我是否犯了任何错误,或者模块和循环不支持 splat 语法?
\nmodule.stamp是地图,而不是列表。以下内容应适用于您的地图:
value = values(module.stamp)[*].location
Run Code Online (Sandbox Code Playgroud)
values将从您的module.stamp.
| 归档时间: |
|
| 查看次数: |
2218 次 |
| 最近记录: |