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 azurerm_managed_identity_federated_identity_credential #18617

Closed
1 task done
timja opened this issue Oct 3, 2022 · 4 comments · Fixed by #19199
Closed
1 task done

Support for azurerm_managed_identity_federated_identity_credential #18617

timja opened this issue Oct 3, 2022 · 4 comments · Fixed by #19199
Assignees
Milestone

Comments

@timja
Copy link
Contributor

timja commented Oct 3, 2022

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 "+1" or "me too" comments, 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

Description

Add support for creating federated identity credentials for managed identity

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

azurerm_managed_identity_federated_identity_credential

Potential Terraform Configuration

I assume basically the same as https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/application_federated_identity_credential

resource "azurerm_managed_identity_federated_identity_credential" "this" {
  managed_identity_object_id = "..."
  issuer = ""
  subject = ""
  name = ""
  audience = ""
}

References

I would like to use this with AKS, (docs for this feature are in this PR: Azure/azure-workload-identity#577)

More info at https://learn.microsoft.com/en-us/azure/aks/workload-identity-overview as well

@piroinno
Copy link

piroinno commented Oct 20, 2022

For those interested I got this working using the azAPI

resource "azapi_resource" "federated_identity_credential" {
  schema_validation_enabled = false
  name                      = var.federated_user_identity
  parent_id                 = data.azurerm_user_assigned_identity.my_user_managed_identity.id
  type                      = "Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials@2022-01-31-preview"

  location = var.location
  body = jsonencode({
    properties = {
      issuer    = azurerm_kubernetes_cluster.mycluster.oidc_issuer_url
      subject   = format("system:serviceaccount:%s:%s", var.namespace, var.aks_service_account)
      audiences = ["api://AzureADTokenExchange"]
    }
  })
  lifecycle {
    ignore_changes = [location]
  }
}

@jkroepke
Copy link
Contributor

For those interested I got this working using the azAPI

This resources in a loop results into concurrency errors:

│ Error: creating/updating "Resource: (ResourceId \"/subscriptions/xxx/resourceGroups/default/providers/Microsoft.ManagedIdentity/userAssignedIdentities/github-actions/federatedIdentityCredentials/repo-jkroepke-homelab-environment-aks\" / Api Version \"2022-01-31-preview\")": PUT https://management.azure.com/subscriptions/xxx/resourceGroups/default/providers/Microsoft.ManagedIdentity/userAssignedIdentities/github-actions/federatedIdentityCredentials/repo-jkroepke-homelab-environment-aks
│ --------------------------------------------------------------------------------
│ RESPONSE 409: 409 Conflict
│ ERROR CODE: ConcurrentFederatedIdentityCredentialsWritesForSingleManagedIdentity
│ --------------------------------------------------------------------------------
│ {
│   "error": {
│     "code": "ConcurrentFederatedIdentityCredentialsWritesForSingleManagedIdentity",
│     "message": "Too many Federated Identity Credentials are written concurrently for the managed identity '/subscriptions/xxx/resourcegroups/default/providers/microsoft.managedidentity/userassignedidentities/github-actions'. Concurrent Federated Identity Credentials writes under the same managed identity are not supported."
│   }
│ }
│ --------------------------------------------------------------------------------
│ 
│ 
│   with module.mi-github-actions.azapi_resource.federated_identity_credential["repo:jkroepke/homelab:environment:aks"],
│   on modules/federated-managed-identity/main.tf line 8, in resource "azapi_resource" "federated_identity_credential":
│    8: resource "azapi_resource" "federated_identity_credential" {
│ 
╵

This should be remembered, it a terraform resources has been created.

favoretti added a commit to favoretti/pandora that referenced this issue Nov 8, 2022
@favoretti favoretti self-assigned this Nov 8, 2022
favoretti added a commit to favoretti/terraform-provider-azurerm that referenced this issue Nov 8, 2022
@github-actions github-actions bot added this to the v3.31.0 milestone Nov 10, 2022
@github-actions
Copy link

This functionality has been released in v3.31.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants