Skip to content

Instantly share code, notes, and snippets.

@iuuso
Created August 31, 2024 11:43
Show Gist options
  • Save iuuso/92e6b96d128377a44b856e045f338c57 to your computer and use it in GitHub Desktop.
Save iuuso/92e6b96d128377a44b856e045f338c57 to your computer and use it in GitHub Desktop.
Github Actions Example for deploying CDKTF applications to Azure using OIDC
name: Deploy CDKTF
on:
push:
branches:
- main
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Install CDKTF
run: npm install --target=global cdktf-cli@latest
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.2.0
terraform_wrapper: false
- name: Azure login
uses: azure/login@v2
with:
auth-type: SERVICE_PRINCIPAL
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: CDKTF Synth
run: npx cdktf synth
- name: CDKTF Deploy
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
run: npx cdktf deploy --auto-approve '*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment