Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_logic_app_workflow - can now be updated when associated with integration_service_environment_id #18660

Merged
merged 3 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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