Hello
I created a bunch of modules and thus far everything is working as intended. I am stuck with something which seems like it should be simple but for the life of me I cannot wrap my head around.
So I have a module to create an Azure app service plan.
Another module to create an Azure webapp (using the above app service plan)
I re-use the webapp module several times to create mutliple webapps.
Question is: Is (and how?) it possible to pass the additional blocks to the webapp module as opposed to have them defined in the module itself? I am referring to specifically the “app settings” & “connection string” blocks. My module currently looks like this:
modules/webapp.tf
resource "azurerm_app_service" "app" {
name = "${lower(var.environment)}-${lower(var.application)}${var.apptype != "" ? "-${var.apptype}-" : "-"}${lower(var.regionabrv)}-wa"
location = var.region
resource_group_name = var.resourcegroup
app_service_plan_id = var.appservice
https_only = "true"
site_config {
dotnet_framework_version = "v4.0"
scm_type = "None"
always_on = "true"
use_32_bit_worker_process = "true"
remote_debugging_enabled = "false"
default_documents = [
"Default.html",
]
}
From my main file I call the module like this:
…main.tf
module "webapp" {
source = "../../_modules/webapp"
resourcegroup = module.resourcegroup.resourcegroup_info.resourcegroup_name
appservice = module.web-serviceplan.appserviceplan_info.app_service_plan_id
environment = var.environment
application = var.application
region = var.region
regionabrv = var.regionabrv
apptype = "web"
appsettings = var.appsettings
}
The missing piece is adding something like the below block (which might contain generated values coming from other modules defined in main.tf, or something different depending on which webapp is being created. Same for connection string block) to the webapp in flight:
app-settings = {
"key1" = "value1"
"APPINSIGHTS_INSTRUMENTATIONKEY" = "${module.appinsights.api_key}"
"key2" = "value2"
"key3" = "value3"
"key4" = "value4"
"msmq:ConString" = "${module.servicebus.default_primary_connection_string}"
Apologies if post is lengthy, but any help would be much appreciated.