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 - purview_id #17001

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions internal/services/datafactory/data_factory_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/services/datafactory/validate"
keyVaultParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/parse"
keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate"
purviewValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/purview/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tags"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down Expand Up @@ -188,6 +189,12 @@ func resourceDataFactory() *pluginsdk.Resource {
Default: true,
},

"purview_id": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: purviewValidate.AccountID,
},

"customer_managed_key_id": {
Type: pluginsdk.TypeString,
Optional: true,
Expand Down Expand Up @@ -248,6 +255,12 @@ func resourceDataFactoryCreateUpdate(d *pluginsdk.ResourceData, meta interface{}
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
}

if purviewId, ok := d.GetOk("purview_id"); ok {
dataFactory.FactoryProperties.PurviewConfiguration = &datafactory.PurviewConfiguration{
PurviewResourceID: utils.String(purviewId.(string)),
}
}

if keyVaultKeyID, ok := d.GetOk("customer_managed_key_id"); ok {
keyVaultKey, err := keyVaultParse.ParseOptionallyVersionedNestedItemID(keyVaultKeyID.(string))
if err != nil {
Expand Down Expand Up @@ -391,6 +404,10 @@ func resourceDataFactoryRead(d *pluginsdk.ResourceData, meta interface{}) error
d.Set("public_network_enabled", resp.PublicNetworkAccess == datafactory.PublicNetworkAccessEnabled)
}

if resp.PurviewConfiguration != nil {
d.Set("purview_id", resp.PurviewConfiguration.PurviewResourceID)
}

managedVirtualNetworkEnabled := false
managedVirtualNetworkName, err := getManagedVirtualNetworkName(ctx, managedVirtualNetworksClient, id.ResourceGroup, id.FactoryName)
if err != nil {
Expand Down
20 changes: 16 additions & 4 deletions internal/services/datafactory/data_factory_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,26 @@ provider "azurerm" {
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-df-%d"
location = "%s"
name = "acctestRG-df-%[1]d"
location = "%[2]s"
}

resource "azurerm_purview_account" "test" {
name = "acctestacc%[3]s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location

identity {
type = "SystemAssigned"
}
}

resource "azurerm_data_factory" "test" {
name = "acctestDF%d"
name = "acctestDF%[1]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
purview_id = azurerm_purview_account.test.id

vsts_configuration {
account_name = "test account name"
branch_name = "test branch name"
Expand All @@ -404,7 +416,7 @@ resource "azurerm_data_factory" "test" {
environment = "production"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (DataFactoryResource) tagsUpdated(data acceptance.TestData) string {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/data_factory.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ In addition to the Arguments listed above - the following Attributes are exporte

- `location` - The Azure Region where the Azure Data Factory exists.

- `purview_id` - (Optional) The ID of purview account.

- `tags` - A mapping of tags assigned to the Azure Data Factory.

- `vsts_configuration` - A `vsts_configuration` block as defined below.
Expand Down