Skip to content

Commit

Permalink
azurerm_logic_app_workflow - can now be updated when associated wit…
Browse files Browse the repository at this point in the history
…h `integration_service_environment_id` (#18660)
  • Loading branch information
mbfrahry authored Oct 7, 2022
1 parent 994b18c commit 5de160a
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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))
}
6 changes: 6 additions & 0 deletions internal/services/logic/logic_app_workflow_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
24 changes: 24 additions & 0 deletions internal/services/logic/logic_app_workflow_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
}

Expand Down Expand Up @@ -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" {
Expand Down
16 changes: 10 additions & 6 deletions internal/services/logic/logic_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -166,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,
}
Expand Down

0 comments on commit 5de160a

Please sign in to comment.