Skip to content

AzureRM backend OIDC authentication hangs during terraform init stage within Github workflow #33826

Open
@delikvent

Description

@delikvent

Terraform Version

Terraform v1.5.6

Terraform Configuration Files

terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "3.71.0"
    }
  }
  backend "azurerm" {}
}

provider "azurerm" {
  features {}
}

data "azurerm_resource_group" "rg" {
  name = "rg-example-1"
}

Debug Output

https://gist.github.com/delikvent/caf426f7c34553adce018b25b314c6c8

Expected Behavior

terraform init stage within github workflow should fail if no matching federated identity record is found for presented assertion.

Actual Behavior

terraform init stage within github workflow hangs (seemingly forever).

Steps to Reproduce

terraform init
-backend-config=subscription_id=REDACTED
-backend-config=resource_group_name=REDACTED
-backend-config=storage_account_name=REDACTED
-backend-config=container_name=REDACTED
-backend-config=key=REDACTED
-input=false

Additional Context

shell:
bash

environment_variables:
ARM_USE_OIDC=TRUE
ARM_CLIENT_ID=REDACTED
ARM_TENANT_ID=REDACTED

github_workflow_permissions:
id-token: write
contents: read

additional_info:
When performing authentication via "az login" instead of "terraform" core binary we can see the expected error message:
<<- ERROR MESSAGE START ->>
AADSTS70021: No matching federated identity record found for presented assertion.
Assertion Issuer: "https://token.actions.githubusercontent.com"
Assertion Subject: REDACTED
Assertion Audience: "api://AzureADTokenExchange"
<<- ERROR MESSAGE END ->>

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions