Terraform: Deploy Logic App
Description
After following “Terraform: Deploy VM”, I then wanted to see how to deploy a Logic App since I have plenty of these I have worked on in the past. Here is what I did (credits to April since I mostly followed this post):
To Resolve:
-
Save an example exported Logic App template as
email_filter.json
source -
Created main.tf
-
Using cloud shell bash, ran a Terraform deployment:
1 2 3 4 5 6
# first, make sure environmental vars are populated from previous steps (see reference to previous post) printenv | grep ^TF_VAR* cd clouddrive mkdir terra2 cd terra2
- Upload
email_filter.json
andmain.tf
using the upload tool.
1 2 3 4 5 6 7 8 9 10
mv email_filter.json main.tf ./clouddrive/terra2/ # Init and install modules terraform init # Creat a plan terraform plan -out main.tfplan # apply the plan terraform apply main.tfplan
- Upload
-
This created a resource group called
email-filter-la
with a Logic App calledemail-filter
.- If you go to Deployments blade on the Resource Group, you can see the deployment
la_deployment_2021-10-06-20-01-18
- If you go to Deployments blade on the Resource Group, you can see the deployment
-
What I will work on next is how to modify an existing Logic App and deploy once again.
- Add an Action to the Logic App
email-filter
. Let’s doInitialize Variable
with variable calledstrName
and a value ofgerry
. - Let’s also clone the Logic App to a new one called
blah
. This is because we want to ensure that a new deployment doesn’t wipe any other Logic Apps in the same RG. To do this, just go to Overview blade and then “clone”. - Now go to Export Template and save the export at
c:\scripts\email_filter.json
source - IMPORTANT! In order to test that incremental overwrites, we need to REVERT the Logic App. This is simple:
- On the Logic App blade, select Versions and
Promote
the original version of the Logic App.
- On the Logic App blade, select Versions and
- Create a new main.tf with
Incremental
instead ofComplete
and then create a new directory to upload the two new files:
1 2 3
cd clouddrive mkdir terra3 cd terra3
- Upload
email_filter.json
andmain.tf
using the upload tool.
1 2 3 4 5 6 7 8 9 10 11 12
mv email_filter.json main.tf ./clouddrive/terra3/ # Init and install modules terraform init # Creat a plan terraform plan -out main.tfplan # Take note of Plan: 1 to add, 0 to change, 0 to destroy. # This means that it does not know it is updating an existing resource. This will be explained below. # apply the plan terraform apply main.tfplan
- Add an Action to the Logic App
-
Notice this time the resource group was left alone and two changes were made:
- If you go to Deployments blade on the Resource Group, you can see the deployment
la_deployment_2021-10-06-20-05-29
- The Logic App should now have the
strName
variable initialized thus overwriting the previously “promoted” version. - If you go to the Activity tab blade, you will see ‘Event Initiated by’ is equal to
az-terraform-sp
as expected.
- If you go to Deployments blade on the Resource Group, you can see the deployment
-
So what’s the problem? The Logic App deployed! Well the problem seems to be that Terraform treats ARM deployments different from the resources they deploy so when you do an update to an existing Logic App, they get out of whack in many scenarios. Here is one issue but I had found others. I will need to look into this more.
Comments