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_data_factory_integration_runtime_managed - support for the credential_name property #25033

Merged
merged 1 commit into from Mar 4, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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"
Expand Down Expand Up @@ -205,6 +206,12 @@ func resourceDataFactoryIntegrationRuntimeManaged() *pluginsdk.Resource {
},
},
},

"credential_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
},
},
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
Expand Up @@ -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{}
Expand Down Expand Up @@ -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 {
Expand Down
Expand Up @@ -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.
Expand Down