diff --git a/management/workspace_environment_type.rego b/management/workspace_environment_type.rego new file mode 100644 index 0000000..b4365b3 --- /dev/null +++ b/management/workspace_environment_type.rego @@ -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 +} diff --git a/management/workspace_environment_type_mock.json b/management/workspace_environment_type_mock.json new file mode 100644 index 0000000..fc8bf5b --- /dev/null +++ b/management/workspace_environment_type_mock.json @@ -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 + } + } + } + } +} diff --git a/management/workspace_environment_type_test.rego b/management/workspace_environment_type_test.rego new file mode 100644 index 0000000..168d804 --- /dev/null +++ b/management/workspace_environment_type_test.rego @@ -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 +}