This skill should be used when the user asks about "kubernetes policy", "gatekeeper", "constraint template", "terraform policy", "conftest", "terraform compliance", "docker policy", "dockerfile policy", "envoy authz", "envoy authorization", "service mesh policy", "cloud policy", "aws policy rego", "azure policy rego", "gcp policy rego", or mentions writing OPA policies for a specific platform. Provides platform-specific Rego patterns and input schemas.
fyrsmithlabs0 starsApr 8, 2026
Occupation
Categories
System Administration
Skill Content
Platform-specific OPA/Rego patterns covering Kubernetes, Terraform, Docker, cloud providers, and service mesh. Each platform has unique input schemas and conventions.
package terraform.aws.s3
import rego.v1
deny contains msg if {
some rc in input.resource_changes
rc.type == "aws_s3_bucket"
"create" in rc.change.actions
not rc.change.after.server_side_encryption_configuration
msg := sprintf("S3 bucket '%s' must have encryption enabled", [rc.address])
}
deny contains msg if {
some rc in input.resource_changes
rc.type == "aws_s3_bucket"
rc.change.after.acl == "public-read"
msg := sprintf("S3 bucket '%s' must not be public", [rc.address])
}
Workflow
# Generate plan JSON
terraform plan -out=tfplan
terraform show -json tfplan > tfplan.json
# Evaluate with Conftest
conftest test tfplan.json -p policy/terraform/
# Evaluate with OPA directly
opa eval -d policy/terraform/ -i tfplan.json "data.terraform.aws.s3.deny"
Common Terraform Policy Categories
Category
Examples
Encryption
S3 SSE, RDS encryption, EBS encryption
Networking
No public IPs, security group restrictions, VPC required
IAM
No wildcard actions, MFA required, role boundaries
package docker.security
import rego.v1
deny contains msg if {
some stage in input.Stages
stage.From.Tag == "latest"
msg := sprintf("stage '%s' uses 'latest' tag - pin to specific version", [stage.Name])
}
deny contains msg if {
some stage in input.Stages
not _has_user(stage)
msg := sprintf("stage '%s' missing USER instruction - must not run as root", [stage.Name])
}
warn contains msg if {
some stage in input.Stages
some cmd in stage.Commands
cmd.Cmd == "add"
msg := "prefer COPY over ADD unless extracting archives"
}
_has_user(stage) if {
some cmd in stage.Commands
cmd.Cmd == "user"
}