Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Sep 30, 2022
1 parent ede5727 commit 28c8fec
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 @@ -44,9 +44,11 @@ locals {
vpn_tunnel_sites = distinct([for k, v in local.vpn_tunnel_outputs : v.site])
# use tunnel secrets if needed
# vpn_site_tunnel_outputs = { for s in local.vpn_tunnel_sites: s => flatten([ for k,v in local.vpn_tunnel_outputs: merge(v,local.vpn_tunnel_secrets[k]) if v.site=s ]) }
vpn_site_tunnel_outputs = { for s in local.vpn_tunnel_sites : s => flatten([for k, v in local.vpn_tunnel_outputs : v if v.site == s]) }
vpn_site_tunnel_outputs = { for s in local.vpn_tunnel_sites : s => flatten([for k, v in local.vpn_tunnel_outputs : v if v.site == s]) }
vpn_site_common_settings = ["account_alias", "account_id", "region", "region_short", "vpc_cidr_block", "vpc_name", "vpc_short_name", "vpn_environment"]
}


resource "null_resource" "directory_setup" {
triggers = {
name = "vpn-configs"
Expand Down Expand Up @@ -92,15 +94,16 @@ resource "local_sensitive_file" "vpn_details_yaml" {
}

resource "local_sensitive_file" "vpn_site_details_json" {
for_each = var.generate_json_files ? local.vpn_site_tunnel_outputs : {}
content = yamlencode({ version = local._module_version, site = each.key, vpns = each.value })
for_each = var.generate_json_files ? local.vpn_site_tunnel_outputs : {}
# content = yamlencode({ version = local._module_version, site = each.key, vpns = each.value })
content = yamlencode(merge({ version = local._module_version, site = each.key, vpns = each.value }, { for k in local.vpn_site_common_settings : k => each.value[0].k }))
filename = format("%v/%v/site.%v.%v.%v.json", path.root, null_resource.directory_setup.triggers.name, local.account_id, local.region, each.key)
file_permission = "0644"
}

resource "local_sensitive_file" "vpn_site_details_yaml" {
for_each = var.generate_yaml_files ? local.vpn_site_tunnel_outputs : {}
content = yamlencode({ version = local._module_version, site = each.key, vpns = each.value })
content = yamlencode(merge({ version = local._module_version, site = each.key, vpns = each.value }, { for k in local.vpn_site_common_settings : k => each.value[0].k }))
filename = format("%v/%v/site.%v.%v.%v.yml", path.root, null_resource.directory_setup.triggers.name, local.account_id, local.region, each.key)
file_permission = "0644"
}
Expand Down

0 comments on commit 28c8fec

Please sign in to comment.