Checking Infrastructure Compliance
Overview
Audit infrastructure configurations against compliance frameworks (CIS Benchmarks, SOC 2, HIPAA, PCI-DSS, GDPR) using policy-as-code tools like Open Policy Agent (OPA), Checkov, and tfsec. Generate compliance reports, identify violations, and produce remediation plans for Terraform, Kubernetes, and cloud provider configurations.
Prerequisites
- Policy-as-code tool installed:
checkov, tfsec, opa, or kube-bench
- Infrastructure-as-code files (Terraform, CloudFormation, Kubernetes manifests) in the project
- Cloud provider CLI authenticated with read access to resources
- Compliance framework requirements documented (CIS, SOC 2, HIPAA, PCI-DSS)
jq for parsing JSON policy outputs
Instructions
- Identify the applicable compliance framework(s) based on industry and data classification
- Scan Terraform files with
checkov -d . or tfsec . to detect misconfigurations
- Scan Kubernetes manifests for security issues: missing resource limits, privileged containers, missing network policies
- Validate IAM policies for least-privilege violations using cloud-native tools (
aws iam access-analyzer)
- Check encryption at rest and in transit: verify S3 bucket encryption, database TLS, and EBS volume encryption
- Audit logging configurations: confirm CloudTrail/Cloud Audit Logs are enabled and sent to immutable storage
- Generate a compliance report mapping each finding to the relevant control (e.g., CIS AWS 2.1.1)
- Produce remediation Terraform/YAML patches for each violation with severity ranking (Critical, High, Medium, Low)
- Set up CI/CD integration so compliance checks block merges on Critical/High violations
Output
- Compliance scan results in JSON/SARIF format for CI integration
- Markdown compliance report with control mappings and pass/fail status
- Remediation code patches (Terraform diffs, Kubernetes manifest updates)
- OPA/Rego policy files for custom organizational rules
- CI/CD pipeline step configuration for automated compliance gating
Error Handling
| Error |
Cause |
Solution |
checkov: no Terraform files found |
Scanner run from wrong directory |
Specify path explicitly with -d path/to/terraform/ |
tfsec: failed to parse HCL |
Syntax error in Terraform files |
Run terraform validate first to fix HCL syntax before compliance scan |
False positive on compliance check |
Rule too broad for the specific use case |
Add inline skip comments (#checkov:skip=CKV_AWS_18:Reason) or create a .checkov.yml skip list |
OPA policy evaluation error |
Rego syntax error or missing input data |
Test policies with opa eval -d policy.rego -i input.json and validate Rego syntax |
Scan timeout on large codebase |
Too many files or complex module references |
Use --compact mode, scan directories individually, or increase timeout limits |
Examples
- "Run a CIS Benchmark compliance check against all Terraform files and generate a report with remediation steps for Critical findings."
- "Create OPA policies that enforce: all S3 buckets must have encryption, all EC2 instances must have IMDSv2, and all security groups must not allow 0.0.0.0/0 ingress."
- "Scan Kubernetes manifests for PCI-DSS compliance: verify no privileged containers, all pods have resource limits, and network policies exist for every namespace."
Resources
Source: jeremylongshore/claude-code-plugins-plus-skills → skills/.curated/checking-infrastructure-compliance/SKILL.md
Also appears in: jeremylongshore/claude-code-plugins-plus-skills/plugins/devops/compliance-checker/skills/checking-infrastructure-compliance/SKILL.md
1---
2name: checking-infrastructure-compliance
3description: "'Execute use when you need to work with compliance checking. This skill provides compliance monitoring and validation with comprehensive guidance and automation. Trigger with phrases like \"check compliance\", \"validate policies\", or \"audit compliance\". '"
4allowed-tools: "Read, Write, Edit, Grep, Glob, Bash(cmd:*)"
5category: security-and-compliance
6source_repo: jeremylongshore/claude-code-plugins-plus-skills
7source_path: "skills/.curated/checking-infrastructure-compliance/SKILL.md"
8source_url: https://github.com/jeremylongshore/claude-code-plugins-plus-skills/blob/HEAD/skills/.curated/checking-infrastructure-compliance/SKILL.md
9metadata:
10 source: https://skillmd.com/skills/thedixitjain/checking-infrastructure-compliance
11---
12
13# Checking Infrastructure Compliance
14
15## Overview
16
17Audit infrastructure configurations against compliance frameworks (CIS Benchmarks, SOC 2, HIPAA, PCI-DSS, GDPR) using policy-as-code tools like Open Policy Agent (OPA), Checkov, and tfsec. Generate compliance reports, identify violations, and produce remediation plans for Terraform, Kubernetes, and cloud provider configurations.
18
19## Prerequisites
20
21- Policy-as-code tool installed: `checkov`, `tfsec`, `opa`, or `kube-bench`
22- Infrastructure-as-code files (Terraform, CloudFormation, Kubernetes manifests) in the project
23- Cloud provider CLI authenticated with read access to resources
24- Compliance framework requirements documented (CIS, SOC 2, HIPAA, PCI-DSS)
25- `jq` for parsing JSON policy outputs
26
27## Instructions
28
291. Identify the applicable compliance framework(s) based on industry and data classification
302. Scan Terraform files with `checkov -d .` or `tfsec .` to detect misconfigurations
313. Scan Kubernetes manifests for security issues: missing resource limits, privileged containers, missing network policies
324. Validate IAM policies for least-privilege violations using cloud-native tools (`aws iam access-analyzer`)
335. Check encryption at rest and in transit: verify S3 bucket encryption, database TLS, and EBS volume encryption
346. Audit logging configurations: confirm CloudTrail/Cloud Audit Logs are enabled and sent to immutable storage
357. Generate a compliance report mapping each finding to the relevant control (e.g., CIS AWS 2.1.1)
368. Produce remediation Terraform/YAML patches for each violation with severity ranking (Critical, High, Medium, Low)
379. Set up CI/CD integration so compliance checks block merges on Critical/High violations
38
39## Output
40
41- Compliance scan results in JSON/SARIF format for CI integration
42- Markdown compliance report with control mappings and pass/fail status
43- Remediation code patches (Terraform diffs, Kubernetes manifest updates)
44- OPA/Rego policy files for custom organizational rules
45- CI/CD pipeline step configuration for automated compliance gating
46
47## Error Handling
48
49| Error | Cause | Solution |
50|-------|-------|---------|
51| `checkov: no Terraform files found` | Scanner run from wrong directory | Specify path explicitly with `-d path/to/terraform/` |
52| `tfsec: failed to parse HCL` | Syntax error in Terraform files | Run `terraform validate` first to fix HCL syntax before compliance scan |
53| `False positive on compliance check` | Rule too broad for the specific use case | Add inline skip comments (`#checkov:skip=CKV_AWS_18:Reason`) or create a `.checkov.yml` skip list |
54| `OPA policy evaluation error` | Rego syntax error or missing input data | Test policies with `opa eval -d policy.rego -i input.json` and validate Rego syntax |
55| `Scan timeout on large codebase` | Too many files or complex module references | Use `--compact` mode, scan directories individually, or increase timeout limits |
56
57## Examples
58
59- "Run a CIS Benchmark compliance check against all Terraform files and generate a report with remediation steps for Critical findings."
60- "Create OPA policies that enforce: all S3 buckets must have encryption, all EC2 instances must have IMDSv2, and all security groups must not allow 0.0.0.0/0 ingress."
61- "Scan Kubernetes manifests for PCI-DSS compliance: verify no privileged containers, all pods have resource limits, and network policies exist for every namespace."
62
63## Resources
64
65- Checkov: https://www.checkov.io/
66- tfsec: https://aquasecurity.github.io/tfsec/
67- Open Policy Agent: https://www.openpolicyagent.org/docs/latest/
68- CIS Benchmarks: https://www.cisecurity.org/cis-benchmarks
69- kube-bench (CIS for Kubernetes): https://github.com/aquasecurity/kube-bench
70
71---
72
73**Source:** [`jeremylongshore/claude-code-plugins-plus-skills`](https://github.com/jeremylongshore/claude-code-plugins-plus-skills) → `skills/.curated/checking-infrastructure-compliance/SKILL.md`
74
75**Also appears in:** `jeremylongshore/claude-code-plugins-plus-skills/plugins/devops/compliance-checker/skills/checking-infrastructure-compliance/SKILL.md`