-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SCALRCORE-31241: Policy example for workspace.environment_type
- Loading branch information
Showing
3 changed files
with
43 additions
and
0 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
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 | ||
} |
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 @@ | ||
{ | ||
"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 | ||
} | ||
} | ||
} | ||
} | ||
} |
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,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 | ||
} |