Create Federated Credential for Managed Identity with Terraform for Github Actions deploying Azure resources

I am trying to add a Federated Credential to a Managed Identity of type GitHub Actions deploying Azure resources.

  • Federated credential scenario = GitHub Actions deploying Azure resources
  • Issuer URL = https://token.actions.MYORG.ghe.com
  • Organization name = my org
  • Organization ID = 1234567
  • Repository name = SRE
  • Repository ID = 1234567
  • Entity = Enviroment
  • Enviroment = utv-test
  • Subject identifier = repo:myorg@myorg-id/sre@repoid:environment:utv-test
  • Credential details name = fc-sre-utv
  • Audience = api://AzureADTokenExchange

I found the resource azurerm_federated_identity_credential but it does not take in enough parameters that i want.


resource "azurerm_federated_identity_credential" "github_environment" {
  name                      = var.github_credential_name
  user_assigned_identity_id = azurerm_user_assigned_identity.deployment.id
  audience                  = ["api://AzureADTokenExchange"]
  issuer                    = var.github_oidc_issuer
  subject                   = var.github_subject_identifier
}

Can anyone point me to the correct azurem resource so that I can create my Federated Credential?

Thanks

Good news: azurerm_federated_identity_credential is the right resource, and it does take everything you need. The Terraform Registry page for it lists exactly the arguments in your snippet: name, user_assigned_identity_id, audience, issuer, subject. The Azure portal form just splits the same credential into more fields, and those collapse into two strings: issuer (your Issuer URL) and subject (your Subject identifier). So you can copy the portal values straight in: issuer = your token.actions…ghe.com URL, subject = the repo:…:environment:utv-test string, audience stays api://AzureADTokenExchange. After the apply the credential should show up in the portal with those same values.