Skip to content

Commit

Permalink
Add support for Integration Account with Integration Service Environm…
Browse files Browse the repository at this point in the history
…ent (#14015)
  • Loading branch information
Neil Ye authored Nov 3, 2021
1 parent 026c03e commit f47d045
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
21 changes: 21 additions & 0 deletions internal/services/logic/logic_app_integration_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ func resourceLogicAppIntegrationAccount() *pluginsdk.Resource {
}, false),
},

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

"tags": tags.Schema(),
},
}
Expand Down Expand Up @@ -93,6 +100,12 @@ func resourceLogicAppIntegrationAccountCreateUpdate(d *pluginsdk.ResourceData, m
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
}

if v, ok := d.GetOk("integration_service_environment_id"); ok {
account.IntegrationAccountProperties.IntegrationServiceEnvironment = &logic.ResourceReference{
ID: utils.String(v.(string)),
}
}

if _, err := client.CreateOrUpdate(ctx, resourceGroup, name, account); err != nil {
return fmt.Errorf("creating Integration Account %q (Resource Group %q): %+v", name, resourceGroup, err)
}
Expand Down Expand Up @@ -130,6 +143,14 @@ func resourceLogicAppIntegrationAccountRead(d *pluginsdk.ResourceData, meta inte
d.Set("location", location.NormalizeNilable(resp.Location))
d.Set("sku_name", string(resp.Sku.Name))

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

return tags.FlattenAndSet(d, resp.Tags)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ func TestAccLogicAppIntegrationAccount_update(t *testing.T) {
})
}

func TestAccLogicAppIntegrationAccount_integrationServiceEnvironment(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_logic_app_integration_account", "test")
r := LogicAppIntegrationAccountResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.integrationServiceEnvironment(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (LogicAppIntegrationAccountResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.IntegrationAccountID(state.ID)
if err != nil {
Expand Down Expand Up @@ -180,3 +195,17 @@ resource "azurerm_logic_app_integration_account" "test" {
}
`, r.template(data), data.RandomInteger)
}

func (r LogicAppIntegrationAccountResource) integrationServiceEnvironment(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
resource "azurerm_logic_app_integration_account" "test" {
name = "acctest-IA-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku_name = "Standard"
integration_service_environment_id = azurerm_integration_service_environment.test.id
}
`, IntegrationServiceEnvironmentResource{}.basic(data), data.RandomInteger)
}
2 changes: 2 additions & 0 deletions website/docs/r/logic_app_integration_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The following arguments are supported:

---

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

* `tags` - (Optional) A mapping of tags which should be assigned to the Logic App Integration Account.

## Attributes Reference
Expand Down

0 comments on commit f47d045

Please sign in to comment.