Skip to content

Commit cdae9fc

Browse files
authored
Merge pull request #316 from recognizegroup/bug/logic-app-standard-deployment
Fix of logic app standard deployment bug
2 parents 0687048 + e56d2be commit cdae9fc

File tree

1 file changed

+30
-8
lines changed
  • modules/azure/logic_app_standard

1 file changed

+30
-8
lines changed

modules/azure/logic_app_standard/main.tf

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ provider "azurerm" {
2222
provider "archive" {
2323
}
2424

25+
locals {
26+
is_linux = length(regexall("/home/", lower(abspath(path.root)))) > 0
27+
}
28+
2529
resource "azurerm_logic_app_standard" "app" {
2630
name = var.logic_app_name
2731
location = var.location
@@ -54,11 +58,26 @@ resource "azurerm_logic_app_standard" "app" {
5458
virtual_network_subnet_id = var.integration_subnet_id
5559
}
5660

57-
# First, create a zip file containing the workflow
58-
data "archive_file" "workflow" {
61+
# First, create a check.zip with archive_file to check diffs (this step is required)
62+
# replacing this step by checking of deploy.zip created by local-exec doesn't work
63+
# because local-exec is not executed during 'plan' so it would take old deploy.zip
64+
data "archive_file" "check_zip" {
5965
type = "zip"
6066
source_dir = var.workflows_source_path
61-
output_path = "${path.module}/files/deploy.zip"
67+
output_path = "${path.module}/files/check.zip"
68+
}
69+
70+
resource "null_resource" "zip_logic_app" {
71+
depends_on = [data.archive_file.check_zip]
72+
73+
triggers = {
74+
deploy = data.archive_file.check_zip.output_sha
75+
}
76+
# if check.zip file changes, create deploy.zip file
77+
provisioner "local-exec" {
78+
interpreter = local.is_linux ? ["bash", "-c"] : ["PowerShell", "-Command"]
79+
command = local.is_linux ? "cd ${path.module} && mkdir -p files && cd ${var.workflows_source_path} && zip -rq $OLDPWD/files/deploy.zip ." : "New-Item -Path \"${path.module}\" -Name \"files\" -ItemType \"directory\" -Force; Compress-Archive -Path \"${var.workflows_source_path}\\*\" -DestinationPath \"${path.module}\\files\\deploy.zip\""
80+
}
6281
}
6382

6483
# After the logic app is created, start a deployment using the Azure CLI
@@ -70,11 +89,14 @@ data "archive_file" "workflow" {
7089
# deployment to make sure the app settings are available before the deployment is started.
7190

7291
resource "time_sleep" "wait_for_app_settings" {
73-
depends_on = [azurerm_logic_app_standard.app]
92+
depends_on = [
93+
azurerm_logic_app_standard.app,
94+
null_resource.zip_logic_app
95+
]
7496
create_duration = "${var.deployment_wait_timeout}s"
7597

7698
triggers = {
77-
time = timestamp()
99+
deploy = data.archive_file.check_zip.output_sha
78100
}
79101
}
80102

@@ -83,7 +105,7 @@ resource "null_resource" "install-extension" {
83105
depends_on = [time_sleep.wait_for_app_settings]
84106

85107
triggers = {
86-
deploy = data.archive_file.workflow.output_sha
108+
deploy = data.archive_file.check_zip.output_sha
87109
}
88110

89111
provisioner "local-exec" {
@@ -99,10 +121,10 @@ resource "null_resource" "deploy" {
99121
depends_on = [null_resource.install-extension]
100122

101123
triggers = {
102-
deploy = data.archive_file.workflow.output_sha
124+
deploy = data.archive_file.check_zip.output_sha
103125
}
104126

105127
provisioner "local-exec" {
106-
command = "az logicapp deployment source config-zip --name ${var.logic_app_name} --resource-group ${var.resource_group_name} --subscription ${data.azurerm_subscription.current.display_name} --src ${data.archive_file.workflow.output_path}"
128+
command = "az logicapp deployment source config-zip --name ${var.logic_app_name} --resource-group ${var.resource_group_name} --subscription ${data.azurerm_subscription.current.display_name} --src ${path.module}/files/deploy.zip"
107129
}
108130
}

0 commit comments

Comments
 (0)