Skip to content

Scheduled Terraform Drift Detection #5

Scheduled Terraform Drift Detection

Scheduled Terraform Drift Detection #5

Workflow file for this run

name: Scheduled Terraform Drift Detection
on:
schedule:
- cron: '0 2 * * *'
jobs:
drift-detection:
name: Check Drift
permissions:
id-token: write
contents: read
pull-requests: read
checks: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Install Terramate
uses: terramate-io/terramate-action@v2
- name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.7.4
terraform_wrapper: false
- name: Authenticate to Google Cloud via OIDC
id: auth
uses: google-github-actions/auth@v2
with:
# see: https://github.com/google-github-actions/auth?tab=readme-ov-file#preferred-direct-workload-identity-federation
project_id: 'gen-ai-hironow'
workload_identity_provider: 'projects/189612961347/locations/global/workloadIdentityPools/github/providers/my-repo'
- name: Run Terraform init on all stacks
id: init
run: terramate run -C stacks -- terraform init
- name: Run drift detection
id: drift
run: |
terramate run \
--sync-drift-status \
--terraform-plan-file=drift.tfplan \
--continue-on-error \
--parallel 5 \
-- \
terraform plan -out drift.tfplan -detailed-exitcode -lock=false
env:
GITHUB_TOKEN: ${{ github.token }}