hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.53k stars 4.6k forks source link

resource "azurerm_logic_app_workflow" didnt support logic app code view template in terraform #27139

Open Muhammad-Imad opened 1 month ago

Muhammad-Imad commented 1 month ago

Is there an existing issue for this?

Community Note

Terraform Version

1.9.3

AzureRM Provider Version

3.0.2

Affected Resource(s)/Data Source(s)

resource "azurerm_logic_app_workflow"

Terraform Configuration Files

resource "azurerm_logic_app_workflow" "example" {
  name                = "example-workflow"
  location            = "West Europe"
  resource_group_name = "example-resources"
  sku_name            = "Consumption"

  definition = <<DEFINITION
{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "actions": {
      "Send_an_email_(V2)": {
        "type": "ApiConnection",
        "inputs": {
          "host": {
            "connection": {
              "name": "@parameters('$connections')['office365']['connectionId']"
            }
          },
          "method": "post",
          "path": "/v2/Mail",
          "body": {
            "subject": "Logic App Output",
            "to": [
              "your-email@domain.com"
            ],
            "body": "Your Logic App output is ready."
          }
        }
      }
    },
    "triggers": {
      "ServiceBusTrigger": {
        "type": "ApiConnection",
        "inputs": {
          "host": {
            "connection": {
              "name": "@parameters('$connections')['servicebus']['connectionId']"
            }
          },
          "method": "get",
          "path": "/queues/{queueName}/messages"
        },
        "recurrence": {
          "frequency": "Minute",
          "interval": 5
        }
      }
    }
  }
}
DEFINITION

  parameters = <<PARAMETERS
{
  "$connections": {
    "value": {
      "servicebus": {
        "connectionId": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Web/connections/servicebus",
        "connectionName": "servicebus",
        "id": "/subscriptions/{subscription-id}/providers/Microsoft.Web/locations/westeurope/managedApis/servicebus"
      },
      "office365": {
        "connectionId": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Web/connections/office365",
        "connectionName": "office365",
        "id": "/subscriptions/{subscription-id}/providers/Microsoft.Web/locations/westeurope/managedApis/office365"
      }
    }
  }
}
PARAMETERS
}

Debug Output/Panic Output

│ Error: Unsupported argument
│ 
│   on main.tf line 1505, in resource "azurerm_logic_app_workflow" "**************":
│ 1505:   definition          = jsonencode({
│ 
│ An argument named "definition" is not expected here.
╵
##[warning]Can't find loc string for key: TerraformPlanFailed
##[error]Error: TerraformPlanFailed 1
Finishing: terraform plan

Expected Behaviour

..

Actual Behaviour

..

Steps to Reproduce

..

Important Factoids

..

References

..

ziyeqf commented 5 days ago

Hi @Muhammad-Imad, thanks for opening the issue.

Currently to define actions inside a azurerm_logic_app_workflow, please use azurerm_logic_app_action_xxx resources (e.x: logic_app_action_custom ), to define triggers, please use azurerm_logic_app_trigger_xxx resources (e.x: azurerm_logic_app_trigger_custom).

To directly use the definition from code view, you can try the azapi provider

For any further questions please leave comments.