Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Sep 19, 2022
1 parent b7c3e9b commit 5f6aec2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions vpn-transit-gateway/vpn-config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ locals {
tunnel1_inside_cidr = aws_vpn_connection.vpn[k].tunnel1_inside_cidr
tunnel1_cgw_inside_address = aws_vpn_connection.vpn[k].tunnel1_cgw_inside_address
tunnel1_vgw_inside_address = aws_vpn_connection.vpn[k].tunnel1_vgw_inside_address
tunnel1_preshared_key = aws_vpn_connection.vpn[k].tunnel1_preshared_key
tunnel1_interface_number = length(v.tunnel_interfaces) == 2 ? v.tunnel_interfaces[0] : ""
tunnel1_loopback = v.tunnel_loopback != null ? v.tunnel_loopback : ""

Expand All @@ -31,11 +30,15 @@ locals {
tunnel2_inside_cidr = aws_vpn_connection.vpn[k].tunnel2_inside_cidr
tunnel2_cgw_inside_address = aws_vpn_connection.vpn[k].tunnel2_cgw_inside_address
tunnel2_vgw_inside_address = aws_vpn_connection.vpn[k].tunnel2_vgw_inside_address
tunnel2_preshared_key = aws_vpn_connection.vpn[k].tunnel2_preshared_key
tunnel2_interface_number = length(v.tunnel_interfaces) == 2 ? v.tunnel_interfaces[1] : ""
tunnel2_loopback = v.tunnel_loopback != null ? v.tunnel_loopback : ""
}
}
vpn_tunnel_secrets = { for k, v in local.vpn_settings : k => {
tunnel1_preshared_key = aws_vpn_connection.vpn[k].tunnel1_preshared_key
tunnel2_preshared_key = aws_vpn_connection.vpn[k].tunnel2_preshared_key
}
}
}

resource "null_resource" "directory_setup" {
Expand Down Expand Up @@ -68,15 +71,15 @@ resource "null_resource" "generate_configs" {
resource "local_sensitive_file" "vpn_details_json" {
for_each = local.vpn_tunnel_outputs
# content = templatefile("${path.module}/templates/vpn_details.tpl"), {
content = jsonencode(merge({ version = local._module_version, name = each.key }, each.value))
content = jsonencode(merge({ version = local._module_version, name = each.key }, each.value, local.vpc_tunnel_secrets[each.key]))
filename = format("${path.root}/%v/%v.%v.%v.json", null_resource.directory_setup.triggers.name, local.account_id, local.region, each.key)
file_permission = "0644"
}

resource "local_sensitive_file" "vpn_details_yaml" {
for_each = local.vpn_tunnel_outputs
# content = templatefile("${path.module}/templates/vpn_details.tpl"), {
content = yamlencode(merge({ version = local._module_version, name = each.key }, each.value))
content = yamlencode(merge({ version = local._module_version, name = each.key }, each.value, local.vpc_tunnel_secrets[each.key]))
filename = format("${path.root}/%v/%v.%v.%v.yml", null_resource.directory_setup.triggers.name, local.account_id, local.region, each.key)
file_permission = "0644"
}

0 comments on commit 5f6aec2

Please sign in to comment.