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 - support for integration_service_environment_id #8504

Merged
merged 8 commits into from
Sep 25, 2020
25 changes: 25 additions & 0 deletions azurerm/internal/services/logic/logic_app_workflow_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ func resourceArmLogicAppWorkflow() *schema.Resource {

"resource_group_name": azure.SchemaResourceGroupName(),

"integration_service_environment_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validate.IntegrationServiceEnvironmentID,
},

"logic_app_integration_account_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -151,6 +158,12 @@ func resourceArmLogicAppWorkflowCreate(d *schema.ResourceData, meta interface{})
Tags: tags.Expand(t),
}

if iseID, ok := d.GetOk("integration_service_environment_id"); ok {
properties.WorkflowProperties.IntegrationServiceEnvironment = &logic.ResourceReference{
ID: utils.String(iseID.(string)),
}
}

if v, ok := d.GetOk("logic_app_integration_account_id"); ok {
properties.WorkflowProperties.IntegrationAccount = &logic.ResourceReference{
ID: utils.String(v.(string)),
Expand Down Expand Up @@ -290,9 +303,21 @@ func resourceArmLogicAppWorkflowRead(d *schema.ResourceData, meta interface{}) e
}
}

integrationServiceEnvironmentId := ""
if props.IntegrationServiceEnvironment != nil && props.IntegrationServiceEnvironment.ID != nil {
integrationServiceEnvironmentId = *props.IntegrationServiceEnvironment.ID
}
d.Set("integration_service_environment_id", integrationServiceEnvironmentId)

if props.IntegrationAccount != nil && props.IntegrationAccount.ID != nil {
d.Set("logic_app_integration_account_id", props.IntegrationAccount.ID)
}

integrationAccountId := ""
if props.IntegrationAccount != nil && props.IntegrationAccount.ID != nil {
integrationAccountId = *props.IntegrationAccount.ID
}
d.Set("logic_app_integration_account_id", integrationAccountId)
}

return tags.FlattenAndSet(d, resp.Tags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ resource "azurerm_subnet" "isesubnet1" {
delegation {
name = "integrationServiceEnvironments"
service_delegation {
name = "Microsoft.Logic/integrationServiceEnvironments"
name = "Microsoft.Logic/integrationServiceEnvironments"
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,25 @@ func TestAccAzureRMLogicAppWorkflow_integrationAccount(t *testing.T) {
})
}

func TestAccAzureRMLogicAppWorkflow_integrationServiceEnvironment(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_logic_app_workflow", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMLogicAppWorkflowDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMLogicAppWorkflow_integrationServiceEnvironment(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMLogicAppWorkflowExists(data.ResourceName),
),
},
data.ImportStep(),
},
})
}

func testCheckAzureRMLogicAppWorkflowExists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
client := acceptance.AzureProvider.Meta().(*clients.Client).Logic.WorkflowClient
Expand Down Expand Up @@ -306,3 +325,17 @@ resource "azurerm_logic_app_workflow" "test" {
}
`, data.RandomInteger, data.Locations.Primary)
}

func testAccAzureRMLogicAppWorkflow_integrationServiceEnvironment(data acceptance.TestData) string {
template := testAccAzureRMIntegrationServiceEnvironment_basic(data)
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
}
`, template, data.RandomInteger)
}
14 changes: 14 additions & 0 deletions azurerm/internal/services/logic/validate/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ func IntegrationServiceEnvironmentName() schema.SchemaValidateFunc {
)
}

func IntegrationServiceEnvironmentID(i interface{}, k string) (warnings []string, errors []error) {
v, ok := i.(string)
if !ok {
errors = append(errors, fmt.Errorf("expected type of %q to be string", k))
return warnings, errors
}

if _, err := parse.IntegrationServiceEnvironmentID(v); err != nil {
errors = append(errors, fmt.Errorf("cannot parse %q as an Integration Service Environment ID: %+v", k, err))
}

return warnings, errors
}

func ValidateSubnetID(i interface{}, k string) (warnings []string, errors []error) {
v, ok := i.(string)
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/logic_app_integration_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The following arguments are supported:

## Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:
In addition to the Arguments listed above - the following Attributes are exported:

* `id` - The ID of the Logic App Integration Account.

Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/logic_app_workflow.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ The following arguments are supported:

* `location` - (Required) Specifies the supported Azure location where the Logic App Workflow exists. Changing this forces a new resource to be created.

* `integration_service_environment_id` - (Optional) The ID of the Integration Service Environment to which this Logic App Workflow belongs. Changing this forces a new Logic App Workflow to be created.

* `logic_app_integration_account_id` - (Optional) The ID of the integration account linked by this Logic App Workflow.

* `workflow_schema` - (Optional) Specifies the Schema to use for this Logic App Workflow. Defaults to `https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#`. Changing this forces a new resource to be created.
Expand Down