Skip to content

Commit e9e787a

Browse files
Add policy checks job to GitHub Actions workflow
Integrates OPA policy enforcement into the CI/CD pipeline: - Adds policy-checks job that runs in parallel with fmt and execute jobs - Uses overmindtech/policy-signals-action@v1 for automated policy enforcement - Generates Terraform plan JSON specifically for policy evaluation - Runs on all pull request events (opened, synchronize, reopened) - Posts policy violation results as PR comments The policy checks will now automatically validate: - Security group configurations (SSH/RDP exposure) - S3 security settings (encryption, tags, public access) - Cost control measures (expensive instances, required tags) Policy violations will be reported as failures in the GitHub Actions run and detailed results will be posted as pull request comments.
1 parent d667c4f commit e9e787a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/automatic.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,34 @@ jobs:
1616
id: fmt
1717
run: terraform fmt -check -diff
1818

19+
# NEW: Policy checks job running in parallel
20+
policy-checks:
21+
runs-on: ubuntu-latest
22+
if: github.event.action != 'closed'
23+
permissions:
24+
contents: read
25+
id-token: write
26+
pull-requests: write
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Terraform Init (for policies)
31+
uses: ./.github/actions/terraform_init/
32+
with:
33+
terraform_deploy_role: ${{ vars.TERRAFORM_DEPLOY_ROLE }}
34+
35+
- name: Generate Plan for Policies
36+
id: policy-plan
37+
run: |
38+
terraform plan -no-color -input=false -out tfplan.policies
39+
terraform show -json tfplan.policies > tfplan.json
40+
41+
- uses: overmindtech/policy-signals-action@v1
42+
with:
43+
policies-path: './policies'
44+
overmind-api-key: ${{ secrets.OVM_API_KEY }}
45+
terraform-plan-json: './tfplan.json'
46+
1947
execute:
2048
runs-on: ubuntu-latest
2149
permissions:

0 commit comments

Comments
 (0)