I have 10+ actions in my Azure Logic app. I keep the action definitions in a JSON file as the content is pretty long, 1K+ lines.
Most actions depend on each other. So, I need to create the actions in a specific order so that Terraform won't fail. I know that I can use as many azurerm_logic_app_action_custom
resources as need and use depends_on
argument. However, this is a lot of repeating the same lines.
So, I am wondering if there a way to create the actions using a loop, perhaps for_each or count, to avoid repeating the same code.
I tried both for_each
and count
but the problem is depends_on
doesn't take dynamic resource names.
Update#1:
resource "azurerm_logic_app_action_custom" "this" {
for_each = local.actions
name = each.key
logic_app_id = azurerm_logic_app_workflow.this.id
body = jsonencode(each.value)
depends_on = [
// here I need to pass the logic app actions that this one
// depends on, perhaps can use actions in runAfter prop
]
}