Skip to content

Commit

Permalink
added opa policy to infracost
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Morgan committed Oct 18, 2024
1 parent 3f96233 commit af35310
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/infracost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ jobs:
--github-token=${{ github.token }} \
--pull-request=${{ github.event.pull_request.number }} \
--behavior=update
--policy-path cost.rego
17 changes: 17 additions & 0 deletions policies/cost.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package infracost

deny[out] {
# maxDiff defines the threshold that you require the cost estimate to be below
maxDiff = 10.0

msg := sprintf(
"Total monthly cost diff must be less than $%.2f (actual diff is $%.2f)",
[maxDiff, to_number(input.diffTotalMonthlyCost)],
)

out := {
# the msg you want to display in your PR comment, must be a string
"msg": msg,
"failed": to_number(input.diffTotalMonthlyCost) >= maxDiff
}
}
2 changes: 1 addition & 1 deletion terraform/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
region = "us-east-1"
instance_type = "t3.small"
instance_type = "t3.large"

0 comments on commit af35310

Please sign in to comment.