You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update all policy files to use older OPA syntax compatible with
Conftest v0.46.0 (OPA 0.57.0) used in GitHub Actions:
- Remove 'import rego.v1' statements
- Change 'contains X if' to 'X[Y]' syntax
- Change 'X in Y' to 'X == Y[_]' syntax
- Fix duplicate package declarations
Tested with Docker using openpolicyagent/conftest:v0.46.0
to match the GitHub Action environment exactly.
Results: 36 tests, 27 passed, 2 warnings, 7 failures
All expected policy violations detected correctly.
msg :=sprintf("Production EC2 instance '%s' - ensure you're using the most cost-effective region", [instance.address])
91
111
}
92
112
93
-
# Warn about RDS instances without backup retention optimization
94
-
warn contains msg if {
95
-
instance := rds_instances[_]
96
-
instance.change.after.backup_retention_period >7
113
+
# Warn about dev instances without auto-shutdown
114
+
warn[msg] {
115
+
instance := ec2_instances[_]
97
116
instance.change.after.tags.Environment =="dev"
98
-
msg :=sprintf("Development RDS instance '%s' has backup retention > 7 days - consider reducing for cost savings", [instance.address])
117
+
not instance.change.after.tags.AutoShutdown
118
+
msg :=sprintf("Development EC2 instance '%s' should have 'AutoShutdown' tag to reduce costs", [instance.address])
99
119
}
100
120
101
-
# Warn about instances with high storage allocation
102
-
warn contains msg if {
103
-
instance:= rds_instances[_]
104
-
instance.change.after.allocated_storage >1000
105
-
msg :=sprintf("RDS instance '%s' has high storage allocation (%d GB) - ensure this is necessary", [instance.address, instance.change.after.allocated_storage])
0 commit comments