Skip to content

Commit

Permalink
make variable to generate files
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Sep 29, 2022
1 parent 736d1af commit 5914edf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions vpn-transit-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ No modules.
| <a name="input_account_id"></a> [account\_id](#input\_account\_id) | AWS Account ID (default: will pull from current user) | `string` | `""` | no |
| <a name="input_create"></a> [create](#input\_create) | Flag to indicate whether to create the resources or not (default: true) | `bool` | `true` | no |
| <a name="input_enable_cloudwatch_logging"></a> [enable\_cloudwatch\_logging](#input\_enable\_cloudwatch\_logging) | Flag to enable or disable VPN tunnel logging to CloudWatch. If Enabled, it will create the cloudwatch log groups | `bool` | `false` | no |
| <a name="input_generate_json_files"></a> [generate\_json\_files](#input\_generate\_json\_files) | Flag to enable or disable generation of JSON file from VPN information | `bool` | `false` | no |
| <a name="input_generate_yaml_files"></a> [generate\_yaml\_files](#input\_generate\_yaml\_files) | Flag to enable or disable generation of YAML file from VPN information | `bool` | `true` | no |
| <a name="input_override_prefixes"></a> [override\_prefixes](#input\_override\_prefixes) | Override built-in prefixes by component. This should be used primarily for common infrastructure things | `map(string)` | `{}` | no |
| <a name="input_profile"></a> [profile](#input\_profile) | AWS Profile Name, used for makign AWS call to download VPN configurations | `string` | `"default"` | no |
| <a name="input_route_table_ids"></a> [route\_table\_ids](#input\_route\_table\_ids) | List of created route table IDs for privating routing to be used for VPN route propagation | `list(string)` | `[]` | no |
Expand Down
13 changes: 13 additions & 0 deletions vpn-transit-gateway/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,16 @@ variable "enable_cloudwatch_logging" {
type = bool
default = false
}

variable "generate_json_files" {
description = "Flag to enable or disable generation of JSON file from VPN information"
type = bool
default = false
}

variable "generate_yaml_files" {
description = "Flag to enable or disable generation of YAML file from VPN information"
type = bool
default = true
}

4 changes: 2 additions & 2 deletions vpn-transit-gateway/vpn-config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ resource "null_resource" "generate_configs" {
}

resource "local_sensitive_file" "vpn_details_json" {
for_each = local.vpn_tunnel_outputs
for_each = var.generate_json_files ? local.vpn_tunnel_outputs : {}
# content = templatefile("${path.module}/templates/vpn_details.tpl"), {
content = jsonencode(merge({ version = local._module_version, vpn_name = each.key }, each.value, local.vpn_tunnel_secrets[each.key]))
filename = format("%v/%v/%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_details_yaml" {
for_each = local.vpn_tunnel_outputs
for_each = var.generate_yaml_files ? local.vpn_tunnel_outputs : {}
# content = templatefile("${path.module}/templates/vpn_details.tpl"), {
content = yamlencode(merge({ version = local._module_version, vpn_name = each.key }, each.value, local.vpn_tunnel_secrets[each.key]))
filename = format("%v/%v/%v.%v.%v.yml", path.root, null_resource.directory_setup.triggers.name, local.account_id, local.region, each.key)
Expand Down

0 comments on commit 5914edf

Please sign in to comment.