Skip to content

Fix Terraform backend authentication to use OIDC instead of storage account keys - #3

Draft
Egoorbis with Claude wants to merge 1 commit into
mainfrom
claude/troubleshoot-terraform-init-issue
Draft

Fix Terraform backend authentication to use OIDC instead of storage account keys#3
Egoorbis with Claude wants to merge 1 commit into
mainfrom
claude/troubleshoot-terraform-init-issue

Conversation

@Claude

@Claude Claude AI commented May 8, 2026

Copy link
Copy Markdown
Contributor

Terraform init was failing with KeyBasedAuthenticationNotPermitted because the Azure Storage Account has key-based authentication disabled, but Terraform defaulted to using storage account keys for backend access.

Changes

  • CD workflow: Added -backend-config="use_oidc=true" to both terraform init commands (plan and apply jobs)
  • CI workflow: Added terraform-plan job that runs on PRs using OIDC authentication
    • Gates on plan environment for OIDC federated credentials
    • Validates infrastructure changes before merge
    • Added id-token: write permission
  • Documentation: Updated CONFIGURATION.md to document OIDC backend requirement

Backend Authentication

terraform init \
  -backend-config="resource_group_name=${{ secrets.BACKEND_RESOURCE_GROUP }}" \
  -backend-config="storage_account_name=${{ secrets.BACKEND_STORAGE_ACCOUNT }}" \
  -backend-config="container_name=${{ secrets.BACKEND_CONTAINER_NAME }}" \
  -backend-config="key=${{ secrets.BACKEND_KEY }}" \
  -backend-config="use_oidc=true"  # ← Uses GitHub OIDC token instead of storage keys

Terraform now authenticates to the backend using the service principal's Storage Blob Data Contributor role via OIDC, aligning with the repository's zero-key security posture.

- Add use_oidc=true to terraform init in CD workflow (plan and apply jobs)
- Add terraform-plan job to CI workflow for PR validation
- Update CONFIGURATION.md to document OIDC backend requirement
- Fixes "KeyBasedAuthenticationNotPermitted" error when storage account has key-based auth disabled

Agent-Logs-Url: https://github.com/Egoorbis/security_agent/sessions/52bcd8e6-4e6b-49e8-a10a-6d5de434a47a

Co-authored-by: Egoorbis <33342912+Egoorbis@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants