API Reference

PREVIEW DOCUMENTATION - This is a preview of a new format for the AWS SDK for Go API Reference documentation. For the current AWS SDK for Go API Reference, see

We welcome your feedback on this new version of the documentation. Send your comments to


import ""

type Rule struct { MetricName *string `type:"string"` Name *string `min:"1" type:"string"` Predicates []*Predicate `type:"list" required:"true"` RuleId *string `min:"1" type:"string" required:"true"` }

A combination of ByteMatchSet, IPSet, and/or SqlInjectionMatchSet objects that identify the web requests that you want to allow, block, or count. For example, you might create a Rule that includes the following predicates:

  • An IPSet that causes AWS WAF to search for web requests that originate from the IP address

  • A ByteMatchSet that causes AWS WAF to search for web requests for which the value of the User-Agent header is BadBot.

To match the settings in this Rule, a request must originate from AND include a User-Agent header for which the value is BadBot.


Type: *string

A friendly name or description for the metrics for this Rule. The name can contain only alphanumeric characters (A-Z, a-z, 0-9); the name can't contain whitespace. You can't change MetricName after you create the Rule.


Type: *string

The friendly name or description for the Rule. You can't change the name of a Rule after you create it.


Specifies the ByteMatchSet, IPSet, SqlInjectionMatchSet, XssMatchSet, RegexMatchSet, GeoMatchSet, and SizeConstraintSet objects that you want to add to a Rule and, for each object, indicates whether you want to negate the settings, for example, requests that do NOT originate from the IP address


Type: *string

A unique identifier for a Rule. You use RuleId to get more information about a Rule (see GetRule), update a Rule (see UpdateRule), insert a Rule into a WebACL or delete a one from a WebACL (see UpdateWebACL), or delete a Rule from AWS WAF (see DeleteRule).

RuleId is returned by CreateRule and by ListRules.

RuleId is a required field



func (s Rule) GoString() string

GoString returns the string representation


func (s *Rule) SetMetricName(v string) *Rule

SetMetricName sets the MetricName field's value.


func (s *Rule) SetName(v string) *Rule

SetName sets the Name field's value.


func (s *Rule) SetPredicates(v []*Predicate) *Rule

SetPredicates sets the Predicates field's value.


func (s *Rule) SetRuleId(v string) *Rule

SetRuleId sets the RuleId field's value.


func (s Rule) String() string

String returns the string representation

On this page: