I am trying to create a Azure logic App workfow using terraform. My module is defined as below :
resource "azurerm_logic_app_workflow" "logic_app_workflow" {
for_each = var.logic_app_workflows
name = each.value["name"]
location = each.value["location"]
resource_group_name = each.value["resource_group_name"]
enabled = each.value["enabled"]
workflow_parameters = { for k,v in each.value["workflow_parameters"] : k =>jsonencode(v) }
tags = each.value["logic_app_workflow_tags"]
}
and my variable is defined as below :
variable "logic_app_workflows" {
type = map(object({
name = string
location = string
resource_group_name = string
enabled = bool
workflow_parameters = any
logic_app_workflow_tags = map(string)
}))
}
My tfvars file looks like this :
logic_app_workflows = {
logic_app_workflow1 = {
name = "logic-app-01"
location = "canadacentral"
resource_group_name = "rg-01"
enabled = true
workflow_parameters = {
defaultValue = []
type = "Object"
}
logic_app_workflow_tags = {
application = "Logic App workflow"
}
}
}
I am receiving the below error when I run apply:
expanding `workflow_parameters`: json: cannot unmarshal array into Go value of type map[string]interface {}
I understand that the error is caused by
workflow_parameters = { for k,v in each.value["workflow_parameters"] : k =>jsonencode(v) }
I tried replacing jsonencode with tostring to see if that might help but got the following error :
Invalid value for "v" parameter: cannot convert tuple to string.
Edit: I tried using the following code but it did not fix the issue.
workflow_parameters = {
defaultValue = []
type = {type = "Object"}
}
Edit 2: I am trying to import an existing logic app workflow, after importing the resource to this module the below screenshot is what terraform plan looks like :
Edit 3: I have tried
workflow_parameters = {
connection = {
defaultValue = {}
type = {type = "Object"}
}
}
But I am getting the following error for terraform plan after importing: