diff --git a/examples/multi_nic_common/README.md b/examples/multi_nic_common/README.md index b8ee7b5..7fdca7a 100644 --- a/examples/multi_nic_common/README.md +++ b/examples/multi_nic_common/README.md @@ -199,7 +199,7 @@ please see https://cloud.google.com/iap/docs/using-tcp-forwarding#increasing_the | [google_compute_instance.linux_vm](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance) | resource | | [google_compute_route.this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_route) | resource | | [local_file.bootstrap_xml](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | -| [local_file.init_cfg](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | +| [local_sensitive_file.init_cfg](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/sensitive_file) | resource | | [google_compute_image.my_image](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_image) | data source | ### Inputs diff --git a/examples/multi_nic_common/main.tf b/examples/multi_nic_common/main.tf index 11635dd..8066de6 100644 --- a/examples/multi_nic_common/main.tf +++ b/examples/multi_nic_common/main.tf @@ -29,20 +29,17 @@ resource "local_file" "bootstrap_xml" { ) } -resource "local_file" "init_cfg" { +resource "local_sensitive_file" "init_cfg" { for_each = { for k, v in var.vmseries : k => v if can(v.bootstrap_template_map) } filename = "files/${each.key}/config/init-cfg.txt" - content = templatefile("templates/init-cfg.tmpl", - { - panorama-server = try(each.value.bootstrap_options.panorama-server, var.vmseries_common.bootstrap_options.panorama-server, "") - type = try(each.value.bootstrap_options.type, var.vmseries_common.bootstrap_options.type, "") - dns-primary = try(each.value.bootstrap_options.dns-primary, var.vmseries_common.bootstrap_options.dns-primary, "") - dns-secondary = try(each.value.bootstrap_options.dns-secondary, var.vmseries_common.bootstrap_options.dns-secondary, "") - }) + content = templatefile( + "templates/init-cfg.tmpl", + { bootstrap_options = merge(var.vmseries_common.bootstrap_options, each.value.bootstrap_options) } + ) } module "bootstrap" { @@ -56,8 +53,8 @@ module "bootstrap" { service_account = module.iam_service_account[each.value.service_account_key].email location = each.value.location files = merge( - { for k, v in var.vmseries : "files/${k}/config/bootstrap.xml" => "${k}/config/bootstrap.xml" }, - { for k, v in var.vmseries : "files/${k}/config/init-cfg.txt" => "${k}/config/init-cfg.txt" }, + { for k, v in var.vmseries : "files/${k}/config/bootstrap.xml" => "${k}/config/bootstrap.xml" if can(v.bootstrap_template_map) }, + { for k, v in var.vmseries : "files/${k}/config/init-cfg.txt" => "${k}/config/init-cfg.txt" if can(v.bootstrap_template_map) }, ) } diff --git a/examples/multi_nic_common/templates/init-cfg.tmpl b/examples/multi_nic_common/templates/init-cfg.tmpl index a15be67..54fe29c 100644 --- a/examples/multi_nic_common/templates/init-cfg.tmpl +++ b/examples/multi_nic_common/templates/init-cfg.tmpl @@ -1,12 +1,3 @@ -%{ if panorama-server != "" ~} -panorama-server=${panorama-server} -%{ endif ~} -%{ if type != "" ~} -type=${type} -%{ endif ~} -%{ if dns-primary != "" ~} -dns-primary=${dns-primary} -%{ endif ~} -%{ if dns-secondary != "" ~} -dns-secondary=${dns-secondary} -%{ endif ~} \ No newline at end of file +%{ for k, v in bootstrap_options ~} +${k}=${v} +%{ endfor ~} \ No newline at end of file diff --git a/examples/vmseries_ha/README.md b/examples/vmseries_ha/README.md index cdb8a82..76071d7 100644 --- a/examples/vmseries_ha/README.md +++ b/examples/vmseries_ha/README.md @@ -253,7 +253,7 @@ Check the succesful inbound and outbound traffic fail-over to and from the spoke | [google_compute_instance.linux_vm](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance) | resource | | [google_compute_route.this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_route) | resource | | [local_file.bootstrap_xml](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | -| [local_file.init_cfg](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | +| [local_sensitive_file.init_cfg](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/sensitive_file) | resource | | [google_compute_image.my_image](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_image) | data source | ### Inputs diff --git a/examples/vmseries_ha/main.tf b/examples/vmseries_ha/main.tf index d5e07fd..771f296 100644 --- a/examples/vmseries_ha/main.tf +++ b/examples/vmseries_ha/main.tf @@ -32,20 +32,17 @@ resource "local_file" "bootstrap_xml" { ) } -resource "local_file" "init_cfg" { +resource "local_sensitive_file" "init_cfg" { for_each = { for k, v in var.vmseries : k => v if can(v.bootstrap_template_map) } filename = "files/${each.key}/config/init-cfg.txt" - content = templatefile("templates/init-cfg.tmpl", - { - panorama-server = try(each.value.bootstrap_options.panorama-server, var.vmseries_common.bootstrap_options.panorama-server, "") - type = try(each.value.bootstrap_options.type, var.vmseries_common.bootstrap_options.type, "") - dns-primary = try(each.value.bootstrap_options.dns-primary, var.vmseries_common.bootstrap_options.dns-primary, "") - dns-secondary = try(each.value.bootstrap_options.dns-secondary, var.vmseries_common.bootstrap_options.dns-secondary, "") - }) + content = templatefile( + "templates/init-cfg.tmpl", + { bootstrap_options = merge(var.vmseries_common.bootstrap_options, each.value.bootstrap_options) } + ) } module "bootstrap" { @@ -59,10 +56,10 @@ module "bootstrap" { service_account = module.iam_service_account[each.value.service_account_key].email location = each.value.location files = merge( - { for k, v in var.vmseries : "files/${k}/config/bootstrap.xml" => "${k}/config/bootstrap.xml" }, - { for k, v in var.vmseries : "files/${k}/config/init-cfg.txt" => "${k}/config/init-cfg.txt" }, + { for k, v in var.vmseries : "files/${k}/config/bootstrap.xml" => "${k}/config/bootstrap.xml" if can(v.bootstrap_template_map) }, + { for k, v in var.vmseries : "files/${k}/config/init-cfg.txt" => "${k}/config/init-cfg.txt" if can(v.bootstrap_template_map) }, ) - depends_on = [local_file.bootstrap_xml, local_file.init_cfg] + depends_on = [local_file.bootstrap_xml, local_sensitive_file.init_cfg] } module "vpc" { diff --git a/examples/vmseries_ha/templates/init-cfg.tmpl b/examples/vmseries_ha/templates/init-cfg.tmpl index a15be67..54fe29c 100644 --- a/examples/vmseries_ha/templates/init-cfg.tmpl +++ b/examples/vmseries_ha/templates/init-cfg.tmpl @@ -1,12 +1,3 @@ -%{ if panorama-server != "" ~} -panorama-server=${panorama-server} -%{ endif ~} -%{ if type != "" ~} -type=${type} -%{ endif ~} -%{ if dns-primary != "" ~} -dns-primary=${dns-primary} -%{ endif ~} -%{ if dns-secondary != "" ~} -dns-secondary=${dns-secondary} -%{ endif ~} \ No newline at end of file +%{ for k, v in bootstrap_options ~} +${k}=${v} +%{ endfor ~} \ No newline at end of file diff --git a/examples/vpc_peering_common/README.md b/examples/vpc_peering_common/README.md index 3a9673a..ec33640 100644 --- a/examples/vpc_peering_common/README.md +++ b/examples/vpc_peering_common/README.md @@ -217,7 +217,7 @@ please see https://cloud.google.com/iap/docs/using-tcp-forwarding#increasing_the | [google_compute_instance.linux_vm](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance) | resource | | [google_compute_route.this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_route) | resource | | [local_file.bootstrap_xml](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | -| [local_file.init_cfg](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | +| [local_sensitive_file.init_cfg](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/sensitive_file) | resource | | [google_compute_image.my_image](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_image) | data source | ### Inputs diff --git a/examples/vpc_peering_common/main.tf b/examples/vpc_peering_common/main.tf index 37923b5..548d4e3 100644 --- a/examples/vpc_peering_common/main.tf +++ b/examples/vpc_peering_common/main.tf @@ -27,20 +27,17 @@ resource "local_file" "bootstrap_xml" { ) } -resource "local_file" "init_cfg" { +resource "local_sensitive_file" "init_cfg" { for_each = { for k, v in var.vmseries : k => v if can(v.bootstrap_template_map) } filename = "files/${each.key}/config/init-cfg.txt" - content = templatefile("templates/init-cfg.tmpl", - { - panorama-server = try(each.value.bootstrap_options.panorama-server, var.vmseries_common.bootstrap_options.panorama-server, "") - type = try(each.value.bootstrap_options.type, var.vmseries_common.bootstrap_options.type, "") - dns-primary = try(each.value.bootstrap_options.dns-primary, var.vmseries_common.bootstrap_options.dns-primary, "") - dns-secondary = try(each.value.bootstrap_options.dns-secondary, var.vmseries_common.bootstrap_options.dns-secondary, "") - }) + content = templatefile( + "templates/init-cfg.tmpl", + { bootstrap_options = merge(var.vmseries_common.bootstrap_options, each.value.bootstrap_options) } + ) } module "bootstrap" { @@ -54,8 +51,8 @@ module "bootstrap" { service_account = module.iam_service_account[each.value.service_account_key].email location = each.value.location files = merge( - { for k, v in var.vmseries : "files/${k}/config/bootstrap.xml" => "${k}/config/bootstrap.xml" }, - { for k, v in var.vmseries : "files/${k}/config/init-cfg.txt" => "${k}/config/init-cfg.txt" }, + { for k, v in var.vmseries : "files/${k}/config/bootstrap.xml" => "${k}/config/bootstrap.xml" if can(v.bootstrap_template_map) }, + { for k, v in var.vmseries : "files/${k}/config/init-cfg.txt" => "${k}/config/init-cfg.txt" if can(v.bootstrap_template_map) }, ) } diff --git a/examples/vpc_peering_common/templates/init-cfg.tmpl b/examples/vpc_peering_common/templates/init-cfg.tmpl index a15be67..54fe29c 100644 --- a/examples/vpc_peering_common/templates/init-cfg.tmpl +++ b/examples/vpc_peering_common/templates/init-cfg.tmpl @@ -1,12 +1,3 @@ -%{ if panorama-server != "" ~} -panorama-server=${panorama-server} -%{ endif ~} -%{ if type != "" ~} -type=${type} -%{ endif ~} -%{ if dns-primary != "" ~} -dns-primary=${dns-primary} -%{ endif ~} -%{ if dns-secondary != "" ~} -dns-secondary=${dns-secondary} -%{ endif ~} \ No newline at end of file +%{ for k, v in bootstrap_options ~} +${k}=${v} +%{ endfor ~} \ No newline at end of file diff --git a/examples/vpc_peering_common_with_network_tags/README.md b/examples/vpc_peering_common_with_network_tags/README.md index 7e9d975..82efb8b 100644 --- a/examples/vpc_peering_common_with_network_tags/README.md +++ b/examples/vpc_peering_common_with_network_tags/README.md @@ -235,7 +235,7 @@ please see https://cloud.google.com/iap/docs/using-tcp-forwarding#increasing_the | [google_compute_instance.linux_vm](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance) | resource | | [google_compute_route.route](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_route) | resource | | [local_file.bootstrap_xml](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | -| [local_file.init_cfg](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | +| [local_sensitive_file.init_cfg](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/sensitive_file) | resource | | [google_compute_image.my_image](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_image) | data source | ### Inputs diff --git a/examples/vpc_peering_common_with_network_tags/main.tf b/examples/vpc_peering_common_with_network_tags/main.tf index b37965d..abf0553 100644 --- a/examples/vpc_peering_common_with_network_tags/main.tf +++ b/examples/vpc_peering_common_with_network_tags/main.tf @@ -27,20 +27,17 @@ resource "local_file" "bootstrap_xml" { ) } -resource "local_file" "init_cfg" { +resource "local_sensitive_file" "init_cfg" { for_each = { for k, v in var.vmseries : k => v if can(v.bootstrap_template_map) } filename = "files/${each.key}/config/init-cfg.txt" - content = templatefile("templates/init-cfg.tmpl", - { - panorama-server = try(each.value.bootstrap_options.panorama-server, var.vmseries_common.bootstrap_options.panorama-server, "") - type = try(each.value.bootstrap_options.type, var.vmseries_common.bootstrap_options.type, "") - dns-primary = try(each.value.bootstrap_options.dns-primary, var.vmseries_common.bootstrap_options.dns-primary, "") - dns-secondary = try(each.value.bootstrap_options.dns-secondary, var.vmseries_common.bootstrap_options.dns-secondary, "") - }) + content = templatefile( + "templates/init-cfg.tmpl", + { bootstrap_options = merge(var.vmseries_common.bootstrap_options, each.value.bootstrap_options) } + ) } module "bootstrap" { @@ -54,8 +51,8 @@ module "bootstrap" { service_account = module.iam_service_account[each.value.service_account_key].email location = each.value.location files = merge( - { for k, v in var.vmseries : "files/${k}/config/bootstrap.xml" => "${k}/config/bootstrap.xml" }, - { for k, v in var.vmseries : "files/${k}/config/init-cfg.txt" => "${k}/config/init-cfg.txt" }, + { for k, v in var.vmseries : "files/${k}/config/bootstrap.xml" => "${k}/config/bootstrap.xml" if can(v.bootstrap_template_map) }, + { for k, v in var.vmseries : "files/${k}/config/init-cfg.txt" => "${k}/config/init-cfg.txt" if can(v.bootstrap_template_map) }, ) } diff --git a/examples/vpc_peering_common_with_network_tags/templates/init-cfg.tmpl b/examples/vpc_peering_common_with_network_tags/templates/init-cfg.tmpl index a15be67..54fe29c 100644 --- a/examples/vpc_peering_common_with_network_tags/templates/init-cfg.tmpl +++ b/examples/vpc_peering_common_with_network_tags/templates/init-cfg.tmpl @@ -1,12 +1,3 @@ -%{ if panorama-server != "" ~} -panorama-server=${panorama-server} -%{ endif ~} -%{ if type != "" ~} -type=${type} -%{ endif ~} -%{ if dns-primary != "" ~} -dns-primary=${dns-primary} -%{ endif ~} -%{ if dns-secondary != "" ~} -dns-secondary=${dns-secondary} -%{ endif ~} \ No newline at end of file +%{ for k, v in bootstrap_options ~} +${k}=${v} +%{ endfor ~} \ No newline at end of file diff --git a/examples/vpc_peering_dedicated/README.md b/examples/vpc_peering_dedicated/README.md index 6fd3453..21db5ba 100644 --- a/examples/vpc_peering_dedicated/README.md +++ b/examples/vpc_peering_dedicated/README.md @@ -231,7 +231,7 @@ The GCP Global HTTP LB acts as a proxy and sends traffic to the VM-Series `Untru | [google_compute_instance.linux_vm](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance) | resource | | [google_compute_route.this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_route) | resource | | [local_file.bootstrap_xml](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | -| [local_file.init_cfg](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | resource | +| [local_sensitive_file.init_cfg](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/sensitive_file) | resource | | [google_compute_image.my_image](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_image) | data source | ### Inputs diff --git a/examples/vpc_peering_dedicated/main.tf b/examples/vpc_peering_dedicated/main.tf index f298dfc..318a65e 100644 --- a/examples/vpc_peering_dedicated/main.tf +++ b/examples/vpc_peering_dedicated/main.tf @@ -27,20 +27,17 @@ resource "local_file" "bootstrap_xml" { ) } -resource "local_file" "init_cfg" { +resource "local_sensitive_file" "init_cfg" { for_each = { for k, v in var.vmseries : k => v if can(v.bootstrap_template_map) } filename = "files/${each.key}/config/init-cfg.txt" - content = templatefile("templates/init-cfg.tmpl", - { - panorama-server = try(each.value.bootstrap_options.panorama-server, var.vmseries_common.bootstrap_options.panorama-server, "") - type = try(each.value.bootstrap_options.type, var.vmseries_common.bootstrap_options.type, "") - dns-primary = try(each.value.bootstrap_options.dns-primary, var.vmseries_common.bootstrap_options.dns-primary, "") - dns-secondary = try(each.value.bootstrap_options.dns-secondary, var.vmseries_common.bootstrap_options.dns-secondary, "") - }) + content = templatefile( + "templates/init-cfg.tmpl", + { bootstrap_options = merge(var.vmseries_common.bootstrap_options, each.value.bootstrap_options) } + ) } module "bootstrap" { @@ -54,8 +51,8 @@ module "bootstrap" { service_account = module.iam_service_account[each.value.service_account_key].email location = each.value.location files = merge( - { for k, v in var.vmseries : "files/${k}/config/bootstrap.xml" => "${k}/config/bootstrap.xml" }, - { for k, v in var.vmseries : "files/${k}/config/init-cfg.txt" => "${k}/config/init-cfg.txt" }, + { for k, v in var.vmseries : "files/${k}/config/bootstrap.xml" => "${k}/config/bootstrap.xml" if can(v.bootstrap_template_map) }, + { for k, v in var.vmseries : "files/${k}/config/init-cfg.txt" => "${k}/config/init-cfg.txt" if can(v.bootstrap_template_map) }, ) } diff --git a/examples/vpc_peering_dedicated/templates/init-cfg.tmpl b/examples/vpc_peering_dedicated/templates/init-cfg.tmpl index a15be67..54fe29c 100644 --- a/examples/vpc_peering_dedicated/templates/init-cfg.tmpl +++ b/examples/vpc_peering_dedicated/templates/init-cfg.tmpl @@ -1,12 +1,3 @@ -%{ if panorama-server != "" ~} -panorama-server=${panorama-server} -%{ endif ~} -%{ if type != "" ~} -type=${type} -%{ endif ~} -%{ if dns-primary != "" ~} -dns-primary=${dns-primary} -%{ endif ~} -%{ if dns-secondary != "" ~} -dns-secondary=${dns-secondary} -%{ endif ~} \ No newline at end of file +%{ for k, v in bootstrap_options ~} +${k}=${v} +%{ endfor ~} \ No newline at end of file