From d590926e44a29ec9921c39f012ccacea90454b0b Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 6 Oct 2022 21:33:44 -0700 Subject: [PATCH 1/3] Fix bug around logic app workflows and integration service environment --- internal/services/logic/logic_apps.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/services/logic/logic_apps.go b/internal/services/logic/logic_apps.go index 79aa680830cf..2997882872fc 100644 --- a/internal/services/logic/logic_apps.go +++ b/internal/services/logic/logic_apps.go @@ -102,10 +102,11 @@ func resourceLogicAppComponentUpdate(d *pluginsdk.ResourceData, meta interface{} properties := logic.Workflow{ Location: read.Location, WorkflowProperties: &logic.WorkflowProperties{ - Definition: definition, - Parameters: read.WorkflowProperties.Parameters, - AccessControl: read.WorkflowProperties.AccessControl, - IntegrationAccount: read.WorkflowProperties.IntegrationAccount, + Definition: definition, + Parameters: read.WorkflowProperties.Parameters, + AccessControl: read.WorkflowProperties.AccessControl, + IntegrationAccount: read.WorkflowProperties.IntegrationAccount, + IntegrationServiceEnvironment: read.IntegrationServiceEnvironment, }, Identity: read.Identity, Tags: read.Tags, From 90aa5b8a7419dd89c36fbf7c8611ec1054c596cf Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 6 Oct 2022 21:38:25 -0700 Subject: [PATCH 2/3] Allow logic app to be updated with ise --- internal/services/logic/logic_app_workflow_resource.go | 6 ++++++ internal/services/logic/logic_apps.go | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/services/logic/logic_app_workflow_resource.go b/internal/services/logic/logic_app_workflow_resource.go index 8eb81b7cac85..aef52b0a4e3b 100644 --- a/internal/services/logic/logic_app_workflow_resource.go +++ b/internal/services/logic/logic_app_workflow_resource.go @@ -438,6 +438,12 @@ func resourceLogicAppWorkflowUpdate(d *pluginsdk.ResourceData, meta interface{}) } } + if iseID, ok := d.GetOk("integration_service_environment_id"); ok { + properties.WorkflowProperties.IntegrationServiceEnvironment = &logic.ResourceReference{ + ID: utils.String(iseID.(string)), + } + } + if _, err = client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, properties); err != nil { return fmt.Errorf("updating Logic App Workflow %s: %+v", id, err) } diff --git a/internal/services/logic/logic_apps.go b/internal/services/logic/logic_apps.go index 2997882872fc..5cf2b6382477 100644 --- a/internal/services/logic/logic_apps.go +++ b/internal/services/logic/logic_apps.go @@ -167,8 +167,11 @@ func resourceLogicAppComponentRemove(d *pluginsdk.ResourceData, meta interface{} properties := logic.Workflow{ Location: read.Location, WorkflowProperties: &logic.WorkflowProperties{ - Definition: definition, - Parameters: read.WorkflowProperties.Parameters, + Definition: definition, + Parameters: read.WorkflowProperties.Parameters, + AccessControl: read.WorkflowProperties.AccessControl, + IntegrationAccount: read.WorkflowProperties.IntegrationAccount, + IntegrationServiceEnvironment: read.IntegrationServiceEnvironment, }, Tags: read.Tags, } From 0f2fa1ca42e70aa1d6d41149bdc090448d0fcc72 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 6 Oct 2022 21:44:18 -0700 Subject: [PATCH 3/3] Add tests --- ..._app_trigger_http_request_resource_test.go | 28 +++++++++++++++++++ .../logic/logic_app_workflow_resource_test.go | 24 ++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/internal/services/logic/logic_app_trigger_http_request_resource_test.go b/internal/services/logic/logic_app_trigger_http_request_resource_test.go index 082f85637e9c..19c48263bbdb 100644 --- a/internal/services/logic/logic_app_trigger_http_request_resource_test.go +++ b/internal/services/logic/logic_app_trigger_http_request_resource_test.go @@ -135,6 +135,22 @@ func TestAccLogicAppTriggerHttpRequest_disappears(t *testing.T) { }) } +func TestAccLogicAppTriggerHttpRequest_workflowWithISE(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_logic_app_trigger_http_request", "test") + r := LogicAppTriggerHttpRequestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.workflowWithISE(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("schema").HasValue("{}"), + ), + }, + data.ImportStep(), + }) +} + func (LogicAppTriggerHttpRequestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { return triggerExists(ctx, clients, state) } @@ -231,3 +247,15 @@ resource "azurerm_logic_app_workflow" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } + +func (r LogicAppTriggerHttpRequestResource) workflowWithISE(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_logic_app_trigger_http_request" "test" { + name = "some-http-trigger" + logic_app_id = azurerm_logic_app_workflow.test.id + schema = "{}" +} +`, LogicAppWorkflowResource{}.integrationServiceEnvironment(data)) +} diff --git a/internal/services/logic/logic_app_workflow_resource_test.go b/internal/services/logic/logic_app_workflow_resource_test.go index 63f65a9a60d5..1704788258c6 100644 --- a/internal/services/logic/logic_app_workflow_resource_test.go +++ b/internal/services/logic/logic_app_workflow_resource_test.go @@ -129,6 +129,13 @@ func TestAccLogicAppWorkflow_integrationServiceEnvironment(t *testing.T) { ), }, data.ImportStep(), + { + Config: r.integrationServiceEnvironmentUpdated(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), }) } @@ -353,6 +360,23 @@ resource "azurerm_logic_app_workflow" "test" { `, IntegrationServiceEnvironmentResource{}.basic(data), data.RandomInteger) } +func (r LogicAppWorkflowResource) integrationServiceEnvironmentUpdated(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_logic_app_workflow" "test" { + name = "acctestlaw-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + integration_service_environment_id = azurerm_integration_service_environment.test.id + + tags = { + "Source" = "AcceptanceTests" + } +} +`, IntegrationServiceEnvironmentResource{}.basic(data), data.RandomInteger) +} + func (LogicAppWorkflowResource) parameters(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" {