Status
Confirmed defect, fixed in Terraform provider v1.15.0, but existing identities must be replaced after upgrading.
In affected versions, the Terraform provider for Octopus saves an empty string "" as the Audience on a service account's OIDC identity when audience isn't set on the octopusdeploy_service_account_oidc_identity resource, so OIDC logins using that identity fail.
Affected versions
Terraform provider for Octopus 0.36.0 to 1.14.0, on any version of Octopus Server. Fixed in v1.15.0+.
Symptom
OIDC login fails even though the issuer and subject match the identity:
Error: Could not find matching identity for presented assertions.
The identity's Audience is "" instead of null in GET /api/serviceaccounts/{serviceAccountId}/oidcidentities/v1?skip=0&take=10.
Why it happens
This is a confirmed defect with the Terraform provider.
When audience isn't set, the provider saves the identity's audience as an empty string instead of null. No token's audience matches "", so login fails.
Workaround
Set audience on the octopusdeploy_service_account_oidc_identity resource in the Terraform configuration to the service account's ID, which is the GUID in the service account's OpenID Connect section, then run terraform apply:
resource "octopusdeploy_service_account_oidc_identity" "example" {
# ...
audience = "<service-account-id>"
}
Keep audience in the Terraform configuration until the provider is upgraded to v1.15.0. Removing it on an earlier provider version sets the audience back to "".
Fix
Upgrade to Terraform provider v1.15.0 or later and replace each affected identity:
terraform apply -replace='octopusdeploy_service_account_oidc_identity.<name>'
After upgrading, audience can be removed from the Terraform configuration, which will set the audience back to null.