-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Derek Morgan
committed
Oct 18, 2024
1 parent
3f96233
commit c271d01
Showing
2 changed files
with
26 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package infracost # You must specify infracost as the Rego package name | ||
|
||
# Each file can have a number of "deny" rules that must return an "out" object | ||
# with keys "msg" & "failed". You can write as many "deny[out]" rule sets as you wish. | ||
# You can read more about rule definitions in Rego here: https://www.openpolicyagent.org/docs/latest/policy-language/#rules | ||
deny[out] { | ||
# maxDiff defines the threshold that you require the cost estimate to be below | ||
maxDiff = 5.0 | ||
|
||
# msg defines the output that will be shown in PR comments under the Policy Checks/Failures section | ||
msg := sprintf( | ||
"Total monthly cost diff must be less than $%.2f (actual diff is $%.2f)", | ||
[maxDiff, to_number(input.diffTotalMonthlyCost)], | ||
) | ||
|
||
# out defines the output for this policy. This output must be formatted with a `msg` and `failed` property. | ||
out := { | ||
# the msg you want to display in your PR comment, must be a string | ||
"msg": msg, | ||
# a boolean value that determines if this policy has failed. | ||
# In this case if the Infracost breakdown output diffTotalMonthlyCost is greater that $5000 | ||
"failed": to_number(input.diffTotalMonthlyCost) >= maxDiff | ||
} | ||
} |