Skip to content

New auth method: Federated Workload Identity (a.k.a OIDC)#438

Merged
magodo merged 3 commits intoAzure:mainfrom
magodo:support_oidc
Jul 26, 2023
Merged

New auth method: Federated Workload Identity (a.k.a OIDC)#438
magodo merged 3 commits intoAzure:mainfrom
magodo:support_oidc

Conversation

@magodo
Copy link
Copy Markdown
Collaborator

@magodo magodo commented Jul 25, 2023

This PR add supports for auth method Federated Workload Identity. In order to use this auth method for github, users need to follow up the https:registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/service_principal_oidc to setup the SP and also the necessary env var. Then launch the command with option: --use-oidc-cred.

A example workflow can be found at: https:github.com/magodo/aztfy-oidc-test/blob/2eaad2c1f47cf369955fb7a1f715a05488faa48f/.github/workflows/test.yaml. Basically, following settings are required:

permissions:
  id-token: write
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
      #...
      - name: Export the demo rg using oidc
        run:
          aztfexport rg -n -f -use-oidc-cred --plain-ui my-rg
        env:
          ARM_USE_OIDC: true
          ARM_TENANT_ID: ${{ secrets. ARM_TENANT_ID }}
          ARM_SUBSCRIPTION_ID: ${{ secrets. ARM_SUBSCRIPTION_ID }}
          ARM_CLIENT_ID: ${{ secrets. ARM_CLIENT_ID }}

Note that the ARM_USE_OIDC env var is necessary to be used for the AzureRM provider.

Fix #436.

@magodo magodo added the enhancement New feature or request label Jul 25, 2023
@magodo magodo requested a review from ms-henglu July 25, 2023 08:16
@magodo magodo requested a review from stemaMSFT July 25, 2023 08:52
Copy link
Copy Markdown
Member

@stemaMSFT stemaMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@magodo magodo merged commit 6b91f93 into Azure:main Jul 26, 2023
@ctahok
Copy link
Copy Markdown

ctahok commented Nov 30, 2023

There is a typo Federated not Fedorated

@magodo magodo changed the title New auth method: Fedorated Workload Identity (a.k.a OIDC) New auth method: Federated Workload Identity (a.k.a OIDC) Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AZTFEXPORT and openID

4 participants