Get DriftHound GitHub Action running in 5 minutes!
- A GitHub repository with Terraform/OpenTofu/Terragrunt code
- Access to a DriftHound instance
- A DriftHound API token
Create drifthound.yaml in your repository root:
default_tool: terraform
tool_versions:
terraform: "1.6.0"
scopes:
- name: "my-infrastructure"
project: "my-app"
environment: "production"
directory: "./terraform"Go to your repository settings → Secrets and add:
DRIFTHOUND_URL- Your DriftHound API URLDRIFTHOUND_TOKEN- Your API token- Cloud provider credentials (e.g.,
AWS_ROLE_ARN)
Create .github/workflows/drift-detection.yml:
name: Drift Detection
on:
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
jobs:
drift-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1
- name: Run drift detection
uses: drifthoundhq/drifthound-action@v1
with:
drifthound-url: ${{ secrets.DRIFTHOUND_URL }}
drifthound-token: ${{ secrets.DRIFTHOUND_TOKEN }}- Go to Actions tab in your GitHub repository
- Find "Drift Detection" workflow
- Click "Run workflow"
- Wait for completion
- Check the summary for results
Your drift detection is now automated. The workflow will:
- Run every 6 hours
- Check your infrastructure for drift
- Report results to DriftHound
- Display a summary in GitHub Actions
- Add more scopes - Monitor multiple projects/environments
- Enable parallel execution - Use matrix strategy for speed
- Configure Slack - Get notifications on drift
- Customize schedule - Adjust cron timing
- Filter scopes - Run specific checks on demand
See README.md for advanced configuration options.
Q: Workflow fails with "401 Unauthorized"
A: Check your DRIFTHOUND_TOKEN secret is correct
Q: Terraform/OpenTofu not found
A: The action installs tools automatically - check your tool name in config
Q: Directory not found
A: Verify the directory path in drifthound.yaml is correct
Q: No drift reported to DriftHound A: Check the workflow logs for API response errors