Pulumi error when using Service Principal Login with the connection information in the pulumi config

Viewed 410

I am using GitHub Actions to run pulumi-pr.yml

I want to be able to deploy to different subscriptions based on the stack.

I created an az ad service principle and put the information in the Pulumi config using the following:

pulumi config set azure:clientId <clientID>
pulumi config set azure:clientSecret <clientSecret> --secret
pulumi config set azure:tenantId <tenantID>
pulumi config set azure:subscriptionId <subscriptionId>

When the GitHub action runs I get the following error:

error: building auth config: obtain subscription() from Azure CLI: Error parsing json result from the Azure CLI: Error waiting for the Azure CLI: exit status 1

Here is the entire yaml:

name: Pulumi Preview

on:
  pull_request:
    branches:
      - main
  workflow_dispatch:

jobs:
  preview:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 1
      - name: Install Pulumi CLI
        uses: pulumi/action-install-pulumi-cli@v1
      - uses: pulumi/actions@v3
        with:
          command: preview
          stack-name: trinsic/Cramer
          work-dir: infrastructure/Source/Trinsic.Okapi
        env:
          PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
1 Answers

The following stack config file (e.g. Pulumi.dev.yaml) and github actions workflow files should work.

Config file (based on https://www.pulumi.com/docs/intro/cloud-providers/azure/setup/#service-principal-authentication)

config:
  azure-native:clientId:
    secure: AAABAJ....BDFDSFSD
  azure-native:clientSecret:
    secure: AAABABebOGe5....BDSFDS
  azure-native:location: CentralUS
  azure-native:subscriptionId:
    secure: AAABAEgNKrTHhf....SFDFSDFSD
  azure-native:tenantId:
    secure: AAABAIoNQ...GDEFSFDSfs

And a workflow file like this:

name: Update:Windows - Config Vars - Manual Trigger

on:
  workflow_dispatch:
    branches:
      - main
jobs:
  up:
    name: Update
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 14.x
      - run: npm install
      - uses: pulumi/actions@v3
        with:
          command: update
          stack-name: dev
        env:
          PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
Related