There are similar questions to this one on Stackoverflow, but none of them addressing my issue in using Terraform when an Azure Storage account is used to retain outputs.
Here is my scenario, which may sound familiar:
My terraform script provisions an Azure HTTP-triggered function with a function key. Also, this terraform script provisions a Web App that calls the mentioned HTTP-triggered function. The HTTP-triggered function's key is stored in the Web App's appsettings.json
file to include it in the HTTP headers' calls to the HTTP-triggered function.
The following code snippet illustrates how the HTTP-triggered function is provisioned in terraform:
resource "azurerm_function_app" "myhttpfunc" {
name = var.funcname
location = "${azurerm_resource_group.rc.location}"
resource_group_name = "${azurerm_resource_group.rc.name}"
app_service_plan_id = "${azurerm_app_service_plan.funcsserviceplan.id}"
storage_account_name = "${azurerm_storage_account.funcstorage.name}"
storage_account_access_key = "${azurerm_storage_account.funcstorage.primary_access_key}"
}
The output variables to access the function's keys is per below:
output "funchostkeys" {
value = data.azurerm_function_app_host_keys.myhttpfunc
sensitive = true
}
I assume that this output and others will appear in terraform.tfstate
hosted on the dedicated Azure Storage account at some point down the road.
My question is that how one can get that particular output in an Azure Release pipeline to manipulate the appsettings.json
file by replacing the configuration entry with what terraform has produced in the output variable?
For example this post suggests producing terraform's output to a file per the following line but that does not seem to be an option in my case because my terraform script leverages Azure storage to retain outputs.
terraform output -json > outputs.json