In terraform I declared a function_app resource:
resource "azurerm_windows_function_app" "func" {
name = local.func_app_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
service_plan_id = azurerm_service_plan.asp.id
storage_account_name = azurerm_storage_account.sa.name
storage_account_access_key = azurerm_storage_account.sa.primary_access_key
app_settings = {
key1 = "value1"
key2 = "value2"
}
}
But i have a new requirements to add a new settings to app_settings.
New settings are placed in list because i iterate over it in another place in a code:
locals {
publish_topics = {
topicTest = "topic1",
topicDev = "topic2"
}
}
How to add static values and values from a list from locals to app_settings config?
Use below terraform code to achieve your requirement.
Refer here for relevant usage of
localsblock and retrieving it usingforeach.Update:
You can also use
for key, value in local.publish_topics : key => valueas suggested by @michasaucer.