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

Support for User managed identity in adf linked service keyvault #26155

Open
1 task done
antgustech opened this issue May 30, 2024 · 2 comments
Open
1 task done

Support for User managed identity in adf linked service keyvault #26155

antgustech opened this issue May 30, 2024 · 2 comments

Comments

@antgustech
Copy link

antgustech commented May 30, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Description

I have the following terraform configuration:

resource "azurerm_data_factory" "this" {
  name                = "adf"
  resource_group_name = var.resource_group
  location            = var.location

  # Managed Identity which is alllowed to access keyvault.
  identity {
    type = "UserAssigned"
    identity_ids = [var.user_assigned_identity_id]
  }
}

resource "azurerm_data_factory_linked_service_key_vault" "this" {
  name            = "keyvault"
  data_factory_id = azurerm_data_factory.this.id
  key_vault_id    = var.keyvaultid
}

resource "azurerm_data_factory_credential_user_managed_identity" "test" {
  name            = "tf"
  description     = "Short description of this credential"
  data_factory_id = azurerm_data_factory.this.id
  identity_id     =   var.user_assigned_identity_id
}

Applying is fine. But there is no way as far as I can see to actually set the linked service to use User managed identity and use the tf credentials.

This is how it looks in azure. It seems to default to be set to "System Assigned Managed Identity":
wrong

And this is what is needed, the dropdown should be set to "User managed identity" and the tf credentials should be selected as well.
correct

New or Affected Resource(s)/Data Source(s)

3.104.2

Potential Terraform Configuration

resource "azurerm_data_factory_linked_service_key_vault" "this" {
  name            = "keyvault"
  data_factory_id = azurerm_data_factory.this.id
  key_vault_id    = var.keyvaultid

  credential_user_managed_identity_id = credential_user_managed_identity.test.id
}

References

I think the issue is similar to: #24742

@antgustech
Copy link
Author

antgustech commented May 31, 2024

I have made this temporary work around, maybe it can help someone else. You can use the custom linked service to provide any json definition that you want. This is how the key vault looks like with a user managed identity:

resource "azurerm_data_factory_credential_user_managed_identity" "test" {
  name            = "tf"
  description     = "Short description of this credential"
  data_factory_id = azurerm_data_factory.this.id
  identity_id     =  var.user_assigned_identity_id
}


# Ideally, azurerm_data_factory_linked_service_key_vault should have been used. Azurerm 3.104.2 and below does not support setting user managed identity so we use a custom linked service for now.
resource "azurerm_data_factory_linked_custom_service" "test" {
  name                 = "test"
  data_factory_id = azurerm_data_factory.this.id
  type                 = "AzureKeyVault"
  type_properties_json = <<JSON
{
  "baseUrl": "https://myvault.vault.azure.net/",
  "credential": {
    "referenceName": "${azurerm_data_factory_credential_user_managed_identity.test.name}",
    "type": "CredentialReference"
    }      
}
JSON
}

@Ramguru94
Copy link

In my use case, i need to have multiple key vault linked services which has its own managed identity as corresponding access policy over the keyvault to have isolation over the secrets across multiple key vaults liked inside ADF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants