aws_waf_rule resource
Use the aws_waf_rule Chef InSpec audit resource to test the properties of a single AWS WAF (web application firewall) rule.
The AWS::WAF::Rule resource type creates a firewall rule that identifies the web requests that you want to allow, block, or count.
For additional information, including details on parameters and properties, see the AWS documentation on the AWS::WAF::Rule resource type.
Syntax
Ensure that a WAF rule exists.
describe aws_waf_rule(rule_id: 'RULE_ID') do
it { should exist }
end
Parameters
rule_id(required)A unique identifier for a WAF rule.
Properties
rule_id- A unique identifier for a rule.
name- The name of the rule.
metric_name- The name of the metrics for this rule.
predicates_negatedFalseif the AWS WAF rule will allow, block, or count requests based on the settings in the specifiedByteMatchSet,IPSet,SqlInjectionMatchSet,XssMatchSet,RegexMatchSet,GeoMatchSet, orSizeConstraintSetobject.predicates_type- The type of predicate in a rule, such as
ByteMatchorIPSet. predicates_data_id- A unique identifier for a predicate in a rule, such as
ByteMatchSetIdorIPSetId.
Examples
Ensure a rule is available:
describe aws_waf_rule(rule_id: 'RULE_ID') do
its('rule_id') { should eq 'RULE_ID' }
end
Ensure a rule name is available:
describe aws_waf_rule(rule_id: 'RULE_ID') do
its('name') { should eq 'RULE_ID_NAME' }
end
Ensure a metric name type is METRIC_NAME:
describe aws_waf_rule(rule_id: 'RULE_ID') do
its('metric_name') { should include 'METRIC_NAME' }
end
Verify the type of data ID should be ‘DATA_ID’:
describe aws_waf_rule(rule_id: 'RULE_ID') do
its('predicates_data_id') { should include 'DATA_ID' }
end
Matchers
For a full list of available matchers, see our Universal Matchers page.This resource has the following special matchers.
exist
Use should to test that the entity exists.
describe aws_waf_rule(rule_id: 'RULE_ID') do
it { should exist }
end
Use should_not to test the entity does not exist.
describe aws_waf_rule(rule_id: 'RULE_ID') do
it { should_not exist }
end
be_available
Use should to check if the entity is available.
describe aws_waf_rule(rule_id: 'RULE_ID') do
it { should be_available }
end
AWS Permissions
Your AWS principal will need the WAF:Client:GetRuleResponse action with Effect set to Allow.