This project enables secure, policy-enforced delivery of Zscaler ZIA and ZPA configurations using:
- Terraform: To define infrastructure-as-code
- OPA (Open Policy Agent) and Conftest: For local and CI policy validation
- Sentinel: For policy enforcement in Terraform Cloud
- GitHub Actions: To run policy checks on PRs and commits
Rego unit tests are defined in policy/test/*.yaml
. These simulate inputs and expected denials.
To run locally:
conftest test --policy policy/ policy/test/
Defined in .github/workflows/zscaler-policy-check.yml
, this runs:
terraform plan
conftest
against the JSON output
Defined in .github/workflows/opa-policy-tests.yml
, this runs all test cases in policy/test/
.
Sentinel policies are defined in sentinel/
.
To enforce in Terraform Cloud:
- Upload policies to a policy set
- Assign the policy set to your workspace
- Use
tfplan/v2
imports for plan evaluation
Policies include:
enforce_https.sentinel
enforce_tags.sentinel
block_all_protocols.sentinel
You can extend this repo to support:
- DLP Rule Checks
- Posture Profile Enforcement
- SCIM Group Rule Validation
This pipeline ensures that all Zscaler IaC changes are:
- Defined as code via Terraform
- Validated against policy guardrails using OPA (locally and in CI)
- Optionally enforced in Terraform Cloud using Sentinel
graph TD
A[Developer Creates Terraform Change] --> B[GitHub Pull Request]
B --> C[Terraform Plan]
C --> D[Run OPA Policy Checks via Conftest]
D -->|Pass| E[Merge Allowed]
D -->|Fail| F[Block Merge & Alert]
E --> G[Terraform Apply]
G --> H[Terraform Cloud Sentinel Policies]
H -->|Pass| I[Deploy Config to Zscaler]
H -->|Fail| J[Rollback / Review]
To use Sentinel:
- Go to Terraform Cloud → Policy Sets
- Create a new policy set and connect to this GitHub repo or upload
.sentinel
files - Assign the policy set to your Zscaler workspace(s)
- Confirm enforcement level (advisory, soft-mandatory, hard-mandatory)
conftest test --policy policy/ policy/test/
Pushing to a branch with .tf
changes triggers:
terraform plan
conftest
policy check- Results shown in GitHub Checks tab