From 4119db7042c40ae1735c394484194bb4490e8729 Mon Sep 17 00:00:00 2001 From: ArtiomMatiom Date: Thu, 31 Oct 2024 10:46:20 +0100 Subject: [PATCH 1/2] Update main.tf --- modules/azure/logic_app_standard/main.tf | 32 ++++++------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/modules/azure/logic_app_standard/main.tf b/modules/azure/logic_app_standard/main.tf index 2ab95c5..63d7bda 100644 --- a/modules/azure/logic_app_standard/main.tf +++ b/modules/azure/logic_app_standard/main.tf @@ -60,20 +60,10 @@ resource "azurerm_logic_app_standard" "app" { virtual_network_subnet_id = var.integration_subnet_id } -# First, create a check.zip with archive_file to check diffs (this step is required) -# replacing this step by checking of deploy.zip created by local-exec doesn't work -# because local-exec is not executed during 'plan' so it would take old deploy.zip -data "archive_file" "check_zip" { - type = "zip" - source_dir = var.workflows_source_path - output_path = "${path.module}/files/check.zip" -} - +# Safest way is to always zip the file, even if there are no changes, it ensures that portal changes do not affect deployment results resource "null_resource" "zip_logic_app" { - depends_on = [data.archive_file.check_zip] - triggers = { - deploy = data.archive_file.check_zip.output_sha + always_run = timestamp() } # if check.zip file changes, create deploy.zip file provisioner "local-exec" { @@ -89,27 +79,18 @@ resource "null_resource" "zip_logic_app" { # the file will not be accepted if the app setting does not exist. However, there is a small delay between # updating the logic app and the app settings being available. Therefore, we need to add a timeout to the # deployment to make sure the app settings are available before the deployment is started. - resource "time_sleep" "wait_for_app_settings" { depends_on = [ azurerm_logic_app_standard.app, null_resource.zip_logic_app ] create_duration = "${var.deployment_wait_timeout}s" - - triggers = { - deploy = data.archive_file.check_zip.output_sha - } } # The first step is to ensure that the logic apps extension is installed resource "null_resource" "install-extension" { depends_on = [time_sleep.wait_for_app_settings] - triggers = { - deploy = data.archive_file.check_zip.output_sha - } - provisioner "local-exec" { command = "az extension add --name logic" } @@ -120,10 +101,13 @@ data "azurerm_subscription" "current" {} # Then use the Azure CLI to start the deployment resource "null_resource" "deploy" { - depends_on = [null_resource.install-extension] + depends_on = [ + null_resource.install-extension, + null_resource.zip_logic_app + ] - triggers = { - deploy = data.archive_file.check_zip.output_sha + triggers = { + always_run = timestamp() # null_resource.zip_logic_app might not always actually change, trigger ensures the execution anyway } provisioner "local-exec" { From 5208ac3cecedf0defd9a4071d102d592fead03b4 Mon Sep 17 00:00:00 2001 From: ArtiomMatiom Date: Thu, 31 Oct 2024 10:53:55 +0100 Subject: [PATCH 2/2] format --- modules/azure/logic_app_standard/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/azure/logic_app_standard/main.tf b/modules/azure/logic_app_standard/main.tf index 63d7bda..76f1771 100644 --- a/modules/azure/logic_app_standard/main.tf +++ b/modules/azure/logic_app_standard/main.tf @@ -102,11 +102,11 @@ data "azurerm_subscription" "current" {} # Then use the Azure CLI to start the deployment resource "null_resource" "deploy" { depends_on = [ - null_resource.install-extension, + null_resource.install-extension, null_resource.zip_logic_app ] - triggers = { + triggers = { always_run = timestamp() # null_resource.zip_logic_app might not always actually change, trigger ensures the execution anyway }