I am facing an issue with Terraform 1.2.6 when trying to create an Azure logic app. I have it set up like this:
# Define the logic app
resource "azurerm_logic_app_workflow" "generic_app" {
name = "generic_app"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
identity {
type = "SystemAssigned"
}
}
# Run the logic app every 5 minutes
resource "azurerm_logic_app_trigger_custom" "generic_app_trigger" {
name = "generic_app_name"
logic_app_id = azurerm_logic_app_workflow.generic_app.id
body = <<BODY
{
"recurrence": {
"frequency": "Minute",
"interval": 5
},
"type": "Recurrence"
}
BODY
}
# Perform the first action
resource "azurerm_logic_app_action_http" "generic_app_action_1" {
name = "HTTP"
logic_app_id = azurerm_logic_app_workflow.generic_app.id
method = "POST"
uri = "https://some-endpoint.com"
headers = {
"authorization" = data.azurerm_key_vault_secret.authtoken_secret.value
"content-type" = "application/x-www-form-urlencoded"
}
}
# Perform the second action if the first action completed
resource "azurerm_logic_app_action_http" "generic_app_action_2" {
name = "HTTP_1"
logic_app_id = azurerm_logic_app_workflow.generic_app.id
depends_on = [azurerm_logic_app_action_http.generic_app_action_1]
method = "POST"
uri = "https://some-endpoint.com"
body = "@decodeBase64(triggerBody()?['ContentData'])"
headers = {
"api-key" = data.azurerm_key_vault_secret.api_key_secret.value
"Authorization" = "Bearer @{body('HTTP').access_token}"
"Accept" = "application/json"
"Content-Type" = "application/json"
}
run_after {
action_name = "HTTP"
action_result = "Succeeded"
}
}
The terraform apply is successful, but in the Logic App Designer the HTTP_1
action body (@decodeBase64(triggerBody()?['ContentData'])
) does not appear correctly:
Instead it should be using the decodeBase64 function and appear like this:
I have also tried using a azurerm_logic_app_action_custom
resource block instead:
resource "azurerm_logic_app_action_custom" "generic_app_action_2" {
name = "HTTP_1"
logic_app_id = azurerm_logic_app_workflow.generic_app.id
depends_on = [azurerm_logic_app_action_http.generic_app_action_1]
body = <<BODY
{
"type": "Http",
"inputs": {
"method": "POST",
"uri": "https://some-endpoint.com",
"body": {
"ContentData": "@{decodeBase64(triggerBody()?['ContentData'])}"
},
"headers": {
"Authorization": "Bearer @{body('HTTP').access_token}",
"Accept": "application/json",
"Content-Type": "application/json"
}
},
"runAfter": {
"HTTP": ["Succeeded"]
}
}
BODY
}
But this is also not working. Is there a way to define functions? Or is this a bug?