Pradeep
Pradeep

Reputation: 5500

Best approach to deploy logic app with workflow using terraform and arm templates?

I am planning to provision the logic app using terraform script. But the workflow of logic app, I am deploying through the arm templates.

Is this recommended approach?

Can anyone suggest me how to deploy the logic app with business flow?

Upvotes: 1

Views: 2224

Answers (1)

Cloudkollektiv
Cloudkollektiv

Reputation: 14669

Logic apps are kind of counter-intuitive when it comes to Terraform. It is an Azure service that is designed to abstract away custom coding with an easy-to-use user interface. Designing something in a user interface often does not work well when using multiple environments (e.g. test, staging, production). This conflicts heavily with one of the main purposes of Terraform: matching infrastructure across multiple environments.

Of course, you can turn to the magic of ARM templates, but mankind did not invent JSON to be readable. And Azure never had a plan to support YAML for ARM templates. So how to proceed from here? I set out our requirements, solution and a terraform example below.

Requirements

  1. Infrastructure is deployed by Terraform.
  2. Infrastructure is deployed in 4 matching environments (i.e. dev, tst, acc, prd).
  3. Configuring parameters for logic apps should be an easy task.
  4. Building logic apps is done in the GUI.

Solution

  1. Create an "empty" logic app resource with azurerm_logic_app_workflow. This resource will be deployed across all environments. It is empty, so you will find the Logic App in the Azure Portal without any content. This means that in your dev environment, you can use the GUI to design the Logic App.
  2. Create a resource which azurerm_resource_group_template_deployment which will only be deployed based on a condition. This condition is true when you supply an arm template path, which will not be the case in the dev environment.
  3. Make sure that azurerm_resource_group_template_deployment depends on azurerm_logic_app_workflow and set deployment_mode = "Incremental". Furthermore you can supply parameters to the logic app by setting parameters_content = jsonencode(var.parameters_map).

Example

A working terraform example can be found on Github.

Note: another high-level Azure service is Data Factory, which faces the same problems when it comes to automatic deployments using Terraform.

Upvotes: 0

Related Questions