Skip to content

Commit

Permalink
SCALRCORE-31241: Policy example for workspace.environment_type
Browse files Browse the repository at this point in the history
  • Loading branch information
lyzohub committed Jul 1, 2024
1 parent a3e212a commit e8778f1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions management/workspace_environment_type.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package terraform

import input.tfrun as tfrun

deny["Monthly cost for dev workspace exceeds $100"] {
tfrun.workspace.environment_type == "development"
tfrun.cost_estimate.proposed_monthly_cost > 100
}
24 changes: 24 additions & 0 deletions management/workspace_environment_type_mock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"mock": {
"valid_input": {
"tfrun": {
"workspace": {
"environment_type": "development"
},
"cost_estimate": {
"proposed_monthly_cost": 50
}
}
},
"invalid_input": {
"tfrun": {
"workspace": {
"environment_type": "development"
},
"cost_estimate": {
"proposed_monthly_cost": 150
}
}
}
}
}
11 changes: 11 additions & 0 deletions management/workspace_environment_type_test.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package terraform

test_dev_workspace_cost_allowed {
result = deny with input as data.mock.valid_input
count(result) == 0
}

test_dev_workspace_cost_denied {
result = deny with input as data.mock.invalid_input
count(result) > 0
}

0 comments on commit e8778f1

Please sign in to comment.