title: Unable to connect the API connection to the logic App via ARM template in terraform
body: <p>In my terraform I have created a logic app and its workflow with the help of a ARM Template. The 2 connections used in the logic app is also created via ARM template. But somehow even though the resources get created in AZURE. But when I got to the logic app, I always have to manually update the connection in the workflow. How can we make it automatic.</p>
  <pre><code>
  //First connection
  
  resource &quot;azurerm_template_deployment&quot; &quot;exampleeventhub&quot; {
    name                = &quot;acctesttemplate-44&quot;
    resource_group_name = Resourcegrpname
  
   template_body = &lt;&lt;DEPLOY
  {
      &quot;$schema&quot;: https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#,
      &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,
      &quot;parameters&quot;: {
          &quot;connections_eventhubs_name&quot;: {
              &quot;defaultValue&quot;: &quot;eventhubs&quot;,
              &quot;type&quot;: &quot;String&quot;
          }
      },
      &quot;variables&quot;: {},
      &quot;resources&quot;: [
          {
              &quot;type&quot;: &quot;Microsoft.Web/connections&quot;,
              &quot;apiVersion&quot;: &quot;2016-06-01&quot;,
              &quot;name&quot;: &quot;[parameters('connections_eventhubs_name')]&quot;,
              &quot;location&quot;: &quot;qwerty&quot;,
              &quot;kind&quot;: &quot;V1&quot;,
              &quot;properties&quot;: {
                  &quot;displayName&quot;: &quot;eventhubconnection&quot;,
                  &quot;statuses&quot;: [
                      {
                          &quot;status&quot;: &quot;Connected&quot;
                      }
                  ],
                  &quot;customParameterValues&quot;: {},
                  &quot;nonSecretParameterValues&quot;: {},
                  &quot;createdTime&quot;: &quot;aaaaa&quot;,
                  &quot;changedTime&quot;: &quot;bbbb&quot;,
                  &quot;api&quot;: {
                      &quot;name&quot;: &quot;[parameters('connections_eventhubs_name')]&quot;,
                      &quot;displayName&quot;: &quot;Event Hubs&quot;,
                      &quot;description&quot;: &quot;Connect to Azure Event Hubs to send and receive events.&quot;,
                      &quot;iconUri&quot;: &quot;[concat('https://connectoricons-prod.azureedge.net/releases/v1.0.1480/1.0.1480.2454/', parameters('connections_eventhubs_name'), '/icon.png')]&quot;,
                      &quot;brandColor&quot;: &quot;#c4d5ff&quot;,
                      &quot;id&quot;: &quot;[concat('/subscriptions/1111/providers/Microsoft.Web/locations/qwerty/managedApis/', parameters('connections_eventhubs_name'))]&quot;,
                      &quot;type&quot;: &quot;Microsoft.Web/locations/managedApis&quot;
                  },
                  &quot;testLinks&quot;: []
              }
          }
      ]
  }
  DEPLOY
      deployment_mode = &quot;Incremental&quot;
    }
  
  
  
  </code></pre>
  <pre><code>//Second connection
  resource &quot;azurerm_template_deployment&quot; &quot;exampledatacollector&quot; {
    name                = &quot;acctesttemplate-45&quot;
    resource_group_name = Resourcegrpname
   template_body = &lt;&lt;DEPLOY
  {
      &quot;$schema&quot;: https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#,
      &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,
      &quot;parameters&quot;: {
          &quot;connections_thengadatacollector_name&quot;: {
              &quot;defaultValue&quot;: &quot;thengadatacollector&quot;,
              &quot;type&quot;: &quot;String&quot;
          }
      },
      &quot;variables&quot;: {},
      &quot;resources&quot;: [
          {
              &quot;type&quot;: &quot;Microsoft.Web/connections&quot;,
              &quot;apiVersion&quot;: &quot;2016-06-01&quot;,
              &quot;name&quot;: &quot;[parameters('connections_thengadatacollector_name')]&quot;,
              &quot;location&quot;: &quot;qwerty&quot;,
              &quot;kind&quot;: &quot;V1&quot;,
              &quot;properties&quot;: {
                  &quot;displayName&quot;: &quot;azuredatacollector&quot;,
                  &quot;statuses&quot;: [
                      {
                          &quot;status&quot;: &quot;Connected&quot;
                      }
                  ],
                  &quot;customParameterValues&quot;: {},
                  &quot;nonSecretParameterValues&quot;: {
                      &quot;username&quot;: &quot;764a2b1e-431d-4e90-87b1-ea6a34dac48f&quot;
                  },
                  &quot;createdTime&quot;: &quot;aaaa&quot;,
                  &quot;changedTime&quot;: &quot;bbbb&quot;,
                  &quot;api&quot;: {
                      &quot;name&quot;: &quot;[parameters('connections_thengadatacollector_name')]&quot;,
                      &quot;displayName&quot;: &quot;Azure Log Analytics Data Collector&quot;,
                      &quot;description&quot;: &quot;Azure Log Analytics Data Collector will send data to any Azure Log Analytics workspace.&quot;,
                      &quot;iconUri&quot;: &quot;[concat('https://connectoricons-prod.azureedge.net/releases/v1.0.1480/1.0.1480.2454/', parameters('connections_thengadatacollector_name'), '/icon.png')]&quot;,
                      &quot;brandColor&quot;: &quot;#0072C6&quot;,
                      &quot;id&quot;: &quot;[concat('/subscriptions/1111/providers/Microsoft.Web/locations/qwerty/managedApis/', parameters('connections_thengadatacollector_name'))]&quot;,
                      &quot;type&quot;: &quot;Microsoft.Web/locations/managedApis&quot;
                  },
                  &quot;testLinks&quot;: []
              }
          }
      ]
  }
  
  DEPLOY
      deployment_mode = &quot;Incremental&quot;
    }
  </code></pre>
  <pre><code>//Logic App
  resource &quot;azurerm_template_deployment&quot; &quot;example&quot; {
    name                = &quot;acctesttemplate-46&quot;
    resource_group_name = Resourcegrpname
  
   template_body = &lt;&lt;DEPLOY
  {
      &quot;$schema&quot;: https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#,
      &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,
      &quot;parameters&quot;: {
          &quot;workflows_logicapp_name&quot;: {
              &quot;defaultValue&quot;: &quot;logicapp&quot;,
              &quot;type&quot;: &quot;String&quot;
          },
          &quot;connections_thengadatacollector_externalid&quot;: {
              &quot;defaultValue&quot;: &quot;/subscriptions/1111/resourceGroups/Resourcegrpname/providers/Microsoft.Web/connections/azureloganalyticsdatacollector&quot;,
              &quot;type&quot;: &quot;String&quot;
          },
          &quot;connections_eventhubs_externalid&quot;: {
              &quot;defaultValue&quot;: &quot;/subscriptions/1111/resourceGroups/Resourcegrpname/providers/Microsoft.Web/connections/eventhubs&quot;,
              &quot;type&quot;: &quot;String&quot;
          }
      },
      &quot;variables&quot;: {},
      &quot;resources&quot;: [
          {
              &quot;type&quot;: &quot;Microsoft.Logic/workflows&quot;,
              &quot;apiVersion&quot;: &quot;2017-07-01&quot;,
              &quot;name&quot;: &quot;[parameters('workflows_logicapp_name')]&quot;,
              &quot;location&quot;: &quot;qwerty&quot;,
              &quot;properties&quot;: {
                  &quot;state&quot;: &quot;Enabled&quot;,
                  &quot;definition&quot;: {
                      &quot;$schema&quot;: https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#,
                      &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,
                      &quot;parameters&quot;: {
                          &quot;$connections&quot;: {
                              &quot;defaultValue&quot;: {},
                              &quot;type&quot;: &quot;Object&quot;
                          }
                      },
                      &quot;triggers&quot;: {
                          &quot;When_events_are_available_in_Event_Hub&quot;: {
                              &quot;recurrence&quot;: {
                                  &quot;frequency&quot;: &quot;Minute&quot;,
                                  &quot;interval&quot;: 3
                              },
                              &quot;splitOn&quot;: &quot;@triggerBody()&quot;,
                              &quot;type&quot;: &quot;ApiConnection&quot;,
                              &quot;inputs&quot;: {
                                  &quot;host&quot;: {
                                      &quot;connection&quot;: {
                                          &quot;name&quot;: &quot;@parameters('$connections')['eventhubs']['connectionId']&quot;
                                      }
                                  },
                                  &quot;method&quot;: &quot;get&quot;,
                                  &quot;path&quot;: &quot;/@{encodeURIComponent('thengaeventhub')}/events/batch/head&quot;,
                                  &quot;queries&quot;: {
                                      &quot;contentType&quot;: &quot;application/octet-stream&quot;,
                                      &quot;maximumEventsCount&quot;: 50
                                  }
                              }
                          }
                      },
                      &quot;actions&quot;: {
                          &quot;Send_Data_2&quot;: {
                              &quot;runAfter&quot;: {},
                              &quot;type&quot;: &quot;ApiConnection&quot;,
                              &quot;inputs&quot;: {
                                  &quot;body&quot;: &quot;@base64ToString(triggerBody()?['ContentData'])&quot;,
                                  &quot;headers&quot;: {
                                      &quot;Log-Type&quot;: &quot;testcustimlog&quot;
                                  },
                                  &quot;host&quot;: {
                                      &quot;connection&quot;: {
                                          &quot;name&quot;: &quot;@parameters('$connections')['thengadatacollector_1']['connectionId']&quot;
                                      }
                                  },
                                  &quot;method&quot;: &quot;post&quot;,
                                  &quot;path&quot;: &quot;/api/logs&quot;
                              }
                          }
                      }
                  },
                  &quot;parameters&quot;: {
                      &quot;$connections&quot;: {
                          &quot;value&quot;: {
                              &quot;thengadatacollector_1&quot;: {
                                  &quot;connectionId&quot;: &quot;[parameters('connections_thengadatacollector_externalid')]&quot;,
                                  &quot;connectionName&quot;: &quot;thengadatacollector&quot;,
                                  &quot;id&quot;: &quot;/subscriptions/1111/providers/Microsoft.Web/locations/qwerty/managedApis/thengadatacollector&quot;
                              },
                              &quot;eventhubs&quot;: {
                                  &quot;connectionId&quot;: &quot;[parameters('connections_eventhubs_externalid')]&quot;,
                                  &quot;connectionName&quot;: &quot;eventhubs&quot;,
                                  &quot;id&quot;: &quot;/subscriptions/1111/providers/Microsoft.Web/locations/qwerty/managedApis/eventhubs&quot;
                              }
                          }
                      }
                  }
              }
          }
      ]
  }
  DEPLOY
      deployment_mode = &quot;Incremental&quot;
    }
  
  </code></pre>