我目前正在努力解决如何在地图列表中搜索地图列表。
locals {
vpn_configurations = [
{
customer_name = "test125231"
custom_path = "test123123"
shared_by = []
nat = false
nat_source_ip = ""
nat_destination_ip = ""
nat_route = ""
tunnels = [
{
tunnel_name = "test-tunnel"
left = "%defaultroute"
leftid = ""
leftsubnet = ""
leftsourceip = ""
rightid = ""
right = ""
rightsubnet = ""
rightsourceip = ""
ike = "aes256-sha256-modp2048"
keyexchange = "ike"
ikev2 = "no"
esp = "aes256-sha256-modp2048"
salifetime = 3600
ikelifetime = 3600
authby = "secret"
# use auto=start when done testing the tunnel
auto = "ondemand"
},
{
tunnel_name = "test-tunnel2"
left = "%defaultroute"
leftid = ""
leftsubnet = ""
leftsourceip = ""
rightid = ""
right = ""
rightsubnet = ""
rightsourceip = ""
ike = "aes256-sha256-modp2048"
keyexchange = "ike"
ikev2 = "no"
esp = "aes256-sha256-modp2048"
salifetime = 3600
ikelifetime = 3600
authby = "secret"
# use auto=start when done testing the tunnel
auto = "ondemand"
}
]
},
{
customer_name = "sdfsdfsd"
custom_path = "sdfsdfsdf"
shared_by = []
nat = false
nat_source_ip = ""
nat_destination_ip = ""
nat_route = ""
tunnels = [
{
tunnel_name = "test-tunnel3"
left = "%defaultroute"
leftid = ""
leftsubnet = ""
leftsourceip = ""
rightid = ""
right = ""
rightsubnet = ""
rightsourceip = ""
ike = "aes256-sha256-modp2048"
keyexchange = "ike"
ikev2 = "no"
esp = "aes256-sha256-modp2048"
salifetime = 3600
ikelifetime = 3600
authby = "secret"
# use auto=start when done testing the tunnel
auto = "ondemand"
},
{
tunnel_name = "test-tunnel4"
left = "%defaultroute"
leftid = ""
leftsubnet = ""
leftsourceip = ""
rightid = ""
right = ""
rightsubnet = ""
rightsourceip = ""
ike = "aes256-sha256-modp2048"
keyexchange = "ike"
ikev2 = "no"
esp = "aes256-sha256-modp2048"
salifetime = 3600
ikelifetime = 3600
authby = "secret"
# use auto=start when done testing the tunnel
auto = "ondemand"
}
]
}
]
}
我正在尝试将每个 vpn 配置的每个隧道传递到 terraform 模板生成器中,以便为与客户关联的每个隧道创建单独的配置文件。
data "template_file" "networking_configs" {
for_each = local.vpn_configurations
template = file("${path.module}/template-files/networking-templates/tunnel-configuration.tpl")
vars = {
tunnel_name = each.value.tunnels["tunnel_name"]
left = each.value.tunnels["left"]
leftid = module.ipsec.public_ip
leftsubnet = each.value.tunnels["leftsubnet"]
leftsourceip = data.aws_network_interface.eni_ip.private_ip
rightid = each.value.tunnels["rightid"]
right = each.value.tunnels["right"]
rightsubnet = each.value.tunnels["rightsubnet"]
rightsourceip = each.value.tunnels["rightsourceip"]
ike = each.value.tunnels["ike"]
keyexchange = each.value.tunnels["keyexchange"]
ikev2 = each.value.tunnels["ikev2"]
esp = each.value.tunnels["esp"]
salifetime = each.value.tunnels["salifetime"]
ikelifetime = each.value.tunnels["ikelifetime"]
authby = each.value.tunnels["authby"]
auto = each.value.tunnels["auto"]
}
}
感谢任何可用的帮助。