Docs

Risk Rules

Configure rules to score Terraform plan changes based on resource types, actions, tags, and custom conditions.

Risk rules define what changes matter to your organization. Each rule specifies conditions to match and a score to add when those conditions are met. Rules are evaluated against every resource change in a Terraform plan, and matching rules contribute to the total risk score.

How scoring works

Risk scores are additive. When a resource change matches multiple rules, each rule's score is added to the total. This allows you to build layered policies:

  • Set a baseline score for production accounts
  • Add points for high-risk resource types
  • Add more points for destructive actions like deletes

Each rule's score is counted once per plan, regardless of how many resources trigger it. If a rule matches 10 resources, it still contributes its score only once to the total.

Condition fields

Rules match against these fields:

FieldDescriptionExample
account_idAWS Account ID123456789012
resource_typeTerraform resource typeaws_db_instance
resource_addressFull Terraform addressmodule.vpc.aws_subnet.main
workspaceTerraform workspace nameproduction
regionAWS regionus-east-1
actionChange actioncreate, update, delete, replace
tag.<key>Resource tag valuetag.environment, tag.team
attribute.<path>Resource attributeattribute.instance_type
cost.monthlyEstimated monthly cost after change5000
cost.diffAbsolute cost difference in dollars500
cost.percentChangePercentage change in cost25
Cost fields require Infracost

Cost fields (cost.monthly, cost.diff, cost.percentChange) are only available when you have configured an Infracost API key. See Cost Estimation for setup instructions.

Operators

OperatorDescriptionExample
equalsExact matchresource_type equals aws_db_instance
notEqualsDoes not matchaction notEquals create
containsString containsresource_type contains iam
notContainsString does not containresource_address notContains test
matchesRegex patternresource_type matches ^aws_iam_.*
inValue in listaction in [delete, replace]
notInValue not in listworkspace notIn [dev, staging]
existsField is presenttag.environment exists
notExistsField is missingtag.cost-center notExists
greaterThanNumeric comparisonattribute.size greaterThan 100
lessThanNumeric comparisonattribute.size lessThan 50

Condition groups

Combine conditions using AND/OR logic. You can nest up to two levels of groups.

AND group - All conditions must match:

resource_type equals aws_db_instance
AND action equals delete

This matches only when both conditions are true.

OR group - Any condition can match:

resource_type equals aws_db_instance
OR resource_type equals aws_rds_cluster

This matches when either condition is true.

Nested groups - Combine AND and OR:

(resource_type equals aws_db_instance OR resource_type equals aws_rds_cluster)
AND action equals delete

This matches database deletions of either type.

Example rules

Production account baseline

Add a baseline risk score for any change in a production account. This stacks with other rules, so a database deletion in production would score higher than in staging.

SettingValue
NameProduction Account Baseline
Score100
Conditionaccount_id equals 123456789012

Block database deletions

Assign a very high score to database deletions to trigger blocking or require multiple approvers.

SettingValue
NameDatabase Deletion
Score2000
Conditionsresource_type in [aws_db_instance, aws_rds_cluster, aws_dynamodb_table] AND action equals delete

With default thresholds, this single rule would require 3 reviewers and potentially block the change.

IAM role modifications

Flag changes to IAM roles as high-risk for security review.

SettingValue
NameIAM Role Change
Score500
Conditionsresource_type contains iam_role AND action in [update, delete]

Security group changes

Network changes can expose services. Add risk for security group modifications.

SettingValue
NameSecurity Group Change
Score300
Conditionsresource_type equals aws_security_group AND action in [create, update]

Production environment tag

Match resources tagged with a production environment, regardless of which account they are in.

SettingValue
NameProduction Tagged Resources
Score150
Conditiontag.environment in [production, prod]

Untagged resources

Flag resources missing required tags. This encourages tagging hygiene.

SettingValue
NameMissing Environment Tag
Score50
Conditiontag.environment notExists

High cost increase

Flag plans that increase monthly infrastructure cost by more than $500. Requires Infracost integration.

SettingValue
NameHigh Cost Increase
Score300
Conditioncost.diff greaterThan 500

Major percentage cost increase

Flag plans that increase cost by more than 25%. Useful for catching proportionally large changes in smaller environments.

SettingValue
NameMajor Cost Percentage Increase
Score200
Conditioncost.percentChange greaterThan 25

Layered rules example

Rules stack together to create nuanced scoring. Consider a database deletion in a production account:

RuleConditionScore
Production Account Baselineaccount_id equals 123456789012+100
Database Deletionresource_type in [aws_db_instance, ...] AND action equals delete+2000
Production Tagged Resourcestag.environment equals production+150
Total2250

This change would be rated Critical (over 1000 points) and require 3 reviewers based on default approval tiers.

The same database deletion in a staging account would only score 2000 points (no account baseline, different tag), still critical but clearly lower risk than production.

Creating rules

  1. Visit PR Reviews → Risk Rules and click the settings icon, or navigate directly to the rules configuration.
  2. Click Create Rule.
  3. Enter a name and description.
  4. Set the risk score (points this rule adds when matched).
  5. Build your condition group using the visual builder or enter conditions directly.
  6. Save the rule.

New rules are enabled by default and immediately apply to new plan evaluations.

Next steps