Skip to content

Error handling improvement for new azuread_application_flexible_federated_identity_credentialΒ #1807

@danquack

Description

@danquack

Community Note

  • Please vote on this issue by adding a πŸ‘ reaction to the original issue to help the community and maintainers prioritise this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritise the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureAD Provider) Version

Affected Resource(s)

  • azuread_application_flexible_federated_identity_credential

Terraform Configuration Files

I was trying to see if I could create the new Flexible FIC but learned that this only works for Terraform Cloud, not TFE. As a result, troubleshooting was a little difficult due to the way the resource errored. Using the Graph API exposed the information I needed.

resource "azuread_application_flexible_federated_identity_credential" "hcp_terraform" {
   application_id             = azuread_application.hcp_terraform.id
   claims_matching_expression = "claims['sub'] matches '${local.sub}'"
   display_name               = "hcp-terraform-workspace"
   audience                   = "api://AzureADTokenExchange"
   issuer                     = "https://tfe.private-instance.com"
 }

resource "msgraph_resource" "flexibile_federated_identity_credential" {
  url         = "applications/${azuread_application.hcp_terraform.object_id}/federatedIdentityCredentials"
  api_version = "beta"

  body = {
    name      = "tfe-application-test"
    issuer    = "https://tfe.private-instance.com"
    audiences = ["api://AzureADTokenExchange"]
    claimsMatchingExpression = {
      value           = "claims['sub'] matches '${local.sub}'"
      languageVersion = 1
    }
  }
}

Debug Output

Error with azuread_application_flexible_federated_identity_credential

β•·
β”‚ Error: adding flexible federated identity credential for Application (Application: "redacted")
β”‚ 
β”‚   with azuread_application_flexible_federated_identity_credential.hcp_terraform,
β”‚   on main.tf line 126, in resource "azuread_application_flexible_federated_identity_credential" "hcp_terraform":
β”‚  126: resource "azuread_application_flexible_federated_identity_credential" "hcp_terraform" {
β”‚ 
β”‚ adding flexible federated identity credential for Application (Application: "redacted")

Error with msgraph_resource

 {
β”‚   "error": {
β”‚     "code": "InvalidFederatedIdentityCredentialValue",
β”‚     "message": "The FederatedIdentityCredential.ClaimsMatchingExpression.Value is invalid. Rule exception: Expression is not supported for applications in this cloud 'Public' using issuer 'https://tfe.private-instance.com'. paramName: FederatedIdentityCredential.ClaimsMatchingExpression.Value, paramValue: claims['sub'] matches 'redacted:*', objectType: Microsoft.Online.DirectoryServices.Application",
β”‚   }
β”‚ }

Panic Output

Expected Behavior

  • The error on the azuread_application_flexible_federated_identity_credential would align to the error from the Graph API

Actual Behavior

Steps to Reproduce

  1. terraform apply

Important Factoids

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions