From b5d401d8986af477c5d1c24ac8500580bfd855e6 Mon Sep 17 00:00:00 2001 From: Heng Lu Date: Tue, 27 Feb 2024 14:42:08 +0800 Subject: [PATCH] `azurerm_data_factory_integration_runtime_managed` - support for the `credential_name` property --- ...ry_integration_runtime_managed_resource.go | 17 +++++ ...tegration_runtime_managed_resource_test.go | 62 +++++++++++++++++++ ..._integration_runtime_managed.html.markdown | 2 + 3 files changed, 81 insertions(+) diff --git a/internal/services/datafactory/data_factory_integration_runtime_managed_resource.go b/internal/services/datafactory/data_factory_integration_runtime_managed_resource.go index 27269cc26150..3f4053198725 100644 --- a/internal/services/datafactory/data_factory_integration_runtime_managed_resource.go +++ b/internal/services/datafactory/data_factory_integration_runtime_managed_resource.go @@ -8,6 +8,7 @@ import ( "regexp" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-sdk/resource-manager/datafactory/2018-06-01/factories" @@ -205,6 +206,12 @@ func resourceDataFactoryIntegrationRuntimeManaged() *pluginsdk.Resource { }, }, }, + + "credential_name": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringIsNotEmpty, + }, }, } } @@ -328,6 +335,10 @@ func resourceDataFactoryIntegrationRuntimeManagedRead(d *pluginsdk.ResourceData, if err := d.Set("custom_setup_script", flattenDataFactoryIntegrationRuntimeManagedSsisCustomSetupScript(ssisProps.CustomSetupScriptProperties, d)); err != nil { return fmt.Errorf("setting `vnet_integration`: %+v", err) } + + if ssisProps.Credential != nil { + d.Set("credential_name", pointer.From(ssisProps.Credential.ReferenceName)) + } } return nil @@ -413,6 +424,12 @@ func expandDataFactoryIntegrationRuntimeManagedSsisProperties(d *pluginsdk.Resou } } + if credentialName := d.Get("credential_name").(string); credentialName != "" { + ssisProperties.Credential = &datafactory.CredentialReference{ + ReferenceName: pointer.To(credentialName), + } + } + return ssisProperties } diff --git a/internal/services/datafactory/data_factory_integration_runtime_managed_resource_test.go b/internal/services/datafactory/data_factory_integration_runtime_managed_resource_test.go index e3ba984ed237..48be9e5c04f3 100644 --- a/internal/services/datafactory/data_factory_integration_runtime_managed_resource_test.go +++ b/internal/services/datafactory/data_factory_integration_runtime_managed_resource_test.go @@ -89,6 +89,21 @@ func TestAccDataFactoryIntegrationRuntimeManaged_customSetupScript(t *testing.T) }) } +func TestAccDataFactoryIntegrationRuntimeManaged_credential(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_data_factory_integration_runtime_managed", "test") + r := IntegrationRuntimeManagedResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.credential(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccDataFactoryIntegrationRuntimeManaged_aadAuth(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_data_factory_integration_runtime_managed", "test") r := IntegrationRuntimeManagedResource{} @@ -345,6 +360,53 @@ resource "azurerm_data_factory_integration_runtime_managed" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) } +func (IntegrationRuntimeManagedResource) credential(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-df-%[2]d" + location = "%[1]s" +} + +resource "azurerm_user_assigned_identity" "test" { + name = "acctestdf%[2]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + +resource "azurerm_data_factory" "test" { + name = "acctestdfirm%[2]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + identity { + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] + } +} + +resource "azurerm_data_factory_credential_user_managed_identity" "test" { + name = "credential%[2]d" + description = "ORIGINAL DESCRIPTION" + data_factory_id = azurerm_data_factory.test.id + identity_id = azurerm_user_assigned_identity.test.id + annotations = ["1"] +} + +resource "azurerm_data_factory_integration_runtime_managed" "test" { + name = "managed-integration-runtime" + data_factory_id = azurerm_data_factory.test.id + location = azurerm_resource_group.test.location + + node_size = "Standard_D8_v3" + + credential_name = azurerm_data_factory_credential_user_managed_identity.test.name +} +`, data.Locations.Primary, data.RandomInteger) +} + func (t IntegrationRuntimeManagedResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := parse.IntegrationRuntimeID(state.ID) if err != nil { diff --git a/website/docs/r/data_factory_integration_runtime_managed.html.markdown b/website/docs/r/data_factory_integration_runtime_managed.html.markdown index 84ed19231847..20581a02c2d4 100644 --- a/website/docs/r/data_factory_integration_runtime_managed.html.markdown +++ b/website/docs/r/data_factory_integration_runtime_managed.html.markdown @@ -57,6 +57,8 @@ The following arguments are supported: * `catalog_info` - (Optional) A `catalog_info` block as defined below. +* `credential_name` - (Optional) The name of the credential to use for the Managed Integration Runtime. + * `custom_setup_script` - (Optional) A `custom_setup_script` block as defined below. * `vnet_integration` - (Optional) A `vnet_integration` block as defined below.