我需要从IP地址列表中生成键/值对的映射。
示例输入:
ips = [ "1.2.3.4", "2.3.4.5"]
期望的输出:
pairs = [ {ip_address="1.2.3.4"}, {ip_address="2.3.4.5"} ]
我的TF输入数据位于openstack_networking_port_v2.vip.*.all_fixed_ips.0
(任意数量的IP地址),我需要为allowed_address_pairs
生成openstack_networking_port_v2
参数,例如:
resource "openstack_networking_port_v2" "port" {
name = "port"
admin_state_up = "true"
network_id = "${openstack_networking_network_v2.net-backend.id}"
allowed_address_pairs = [
{ ip_address = "1.2.3.4" },
{ ip_address = "2.3.4.5" }
]
}
但当然,从以下资源动态声明allowed_address_pairs
:
resource "openstack_networking_port_v2" "vip" {
name = "vip-${count.index}"
network_id = "${openstack_networking_network_v2.net-backend.id}"
admin_state_up = "true"
count = "10"
}
有任何线索吗?