From 0611d66be7eceab3e4ea2fbce917576933b2f5c3 Mon Sep 17 00:00:00 2001 From: Simone Ruffilli Date: Tue, 25 Oct 2022 18:07:38 +0200 Subject: [PATCH] SimpleNVA: add the option to create additional files --- modules/cloud-config-container/simple-nva/main.tf | 10 ++++++++-- modules/cloud-config-container/simple-nva/variables.tf | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/cloud-config-container/simple-nva/main.tf b/modules/cloud-config-container/simple-nva/main.tf index 5b9663bd3..4ff0afe29 100644 --- a/modules/cloud-config-container/simple-nva/main.tf +++ b/modules/cloud-config-container/simple-nva/main.tf @@ -21,7 +21,7 @@ locals { network_interfaces = local.network_interfaces })) - files = { + files = merge({ "/var/run/nva/ipprefix_by_netmask.sh" = { content = file("${path.module}/files/ipprefix_by_netmask.sh") owner = "root" @@ -32,7 +32,13 @@ locals { owner = "root" permissions = "0744" } - } + }, { + for path, attrs in var.files : path => { + content = attrs.content, + owner = attrs.owner, + permissions = attrs.permissions + } + }) network_interfaces = [ for index, interface in var.network_interfaces : { diff --git a/modules/cloud-config-container/simple-nva/variables.tf b/modules/cloud-config-container/simple-nva/variables.tf index 9307ddace..3c2ebfcbf 100644 --- a/modules/cloud-config-container/simple-nva/variables.tf +++ b/modules/cloud-config-container/simple-nva/variables.tf @@ -20,6 +20,16 @@ variable "cloud_config" { default = null } +variable "files" { + description = "Map of extra files to create on the instance, path as key. Owner and permissions will use defaults if null." + type = map(object({ + content = string + owner = string + permissions = string + })) + default = {} +} + variable "enable_health_checks" { description = "Configures routing to enable responses to health check probes." type = bool