TFGaurd in Azure Pipelines:
CI Terraform Security Setup
A complete azure-pipelines.yml with multi-stage security gates, fail-on-violation configuration, and Azure DevOps branch policy integration.
Azure Pipelines powers infrastructure deployments for some of the world's largest enterprises — and it's exactly where a terraform security tool for CI like TFGaurd has the highest leverage.
This guide provides a production-ready azure-pipelines.yml with multi-stage design: Terraform init, plan generation, TFGaurd security scan, and optional apply. Each stage feeds into the next, ensuring security is never skipped.
Enterprise Note: TFGaurd is fully compatible with Azure DevOps self-hosted agents running on Windows (PowerShell) and Linux (bash). No internet access required beyond fetching the TFGaurd binary on first install.
Complete azure-pipelines.yml
Setting Up Azure DevOps Variable Groups
Store secrets in Pipelines → Library → Variable Groups. Link the group to your pipeline using the group: key:
Variables in the group to configure:
ARM_CLIENT_ID,ARM_CLIENT_SECRET,ARM_TENANT_ID,ARM_SUBSCRIPTION_ID— Azure credentialsTFGAURD_API_KEY— Optional; unlocks premium multi-cloud rules
Enforcing Branch Policies
To block PRs with security violations from being completed, enable the Build Validation branch policy in Repos → Branches → Branch Policies → Build Validation. Select your TFGaurd pipeline as a required status check.
Enterprise Tip: In Azure DevOps, you can also add a Required Reviewer to the Security stage — meaning a security engineer must approve the scan results before apply proceeds. This creates a dual gate: automated + human.
Secure Your Azure DevOps Pipeline
TFGaurd integrates with Azure Pipelines in minutes. Free for AWS teams. Premium unlocks Azure, GCP, and Oracle rules.
Start Free Trial