/AWS1/IF_WAF=>CREATERULE()¶
About CreateRule¶
This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide.
For the latest version of AWS WAF, use the AWS WAFV2 API and see the AWS WAF Developer Guide. With the latest version, AWS WAF has a single set of endpoints for regional and global use.
Creates a Rule, which contains the IPSet objects,
ByteMatchSet objects, and other predicates that identify the requests that
you want to block. If you add more than one predicate to a Rule, a request
must match all of the specifications to be allowed or blocked. For example, suppose
that
you add the following to a Rule:
-
An
IPSetthat matches the IP address192.0.2.44/32 -
A
ByteMatchSetthat matchesBadBotin theUser-Agentheader
You then add the Rule to a WebACL and specify that you want to blocks requests that satisfy the Rule.
For a request to be blocked, it must come from the IP address 192.0.2.44 and the User-Agent header in the request
must contain the value BadBot.
To create and configure a Rule, perform the following steps:
-
Create and update the predicates that you want to include in the
Rule. For more information, see CreateByteMatchSet, CreateIPSet, and CreateSqlInjectionMatchSet. -
Use GetChangeToken to get the change token that you provide in the
ChangeTokenparameter of aCreateRulerequest. -
Submit a
CreateRulerequest. -
Use
GetChangeTokento get the change token that you provide in theChangeTokenparameter of an UpdateRule request. -
Submit an
UpdateRulerequest to specify the predicates that you want to include in theRule. -
Create and update a
WebACLthat contains theRule. For more information, see CreateWebACL.
For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.
Method Signature¶
METHODS /AWS1/IF_WAF~CREATERULE
IMPORTING
!IV_NAME TYPE /AWS1/WAFRESOURCENAME OPTIONAL
!IV_METRICNAME TYPE /AWS1/WAFMETRICNAME OPTIONAL
!IV_CHANGETOKEN TYPE /AWS1/WAFCHANGETOKEN OPTIONAL
!IT_TAGS TYPE /AWS1/CL_WAFTAG=>TT_TAGLIST OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_wafcreateruleresponse
RAISING
/AWS1/CX_WAFWAFBADREQUESTEX
/AWS1/CX_WAFWAFDISALWEDNAMEEX
/AWS1/CX_WAFWAFINTERNALERROREX
/AWS1/CX_WAFWAFINVALIDPARAMEX
/AWS1/CX_WAFWAFLIMITSEXCDEX
/AWS1/CX_WAFWAFSTALEDATAEX
/AWS1/CX_WAFWAFTAGOPERATIONEX
/AWS1/CX_WAFWAFTAGOPINTERNAL00
/AWS1/CX_WAFCLIENTEXC
/AWS1/CX_WAFSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_name TYPE /AWS1/WAFRESOURCENAME /AWS1/WAFRESOURCENAME¶
A friendly name or description of the Rule. You can't change the name of a
Ruleafter you create it.
iv_metricname TYPE /AWS1/WAFMETRICNAME /AWS1/WAFMETRICNAME¶
A friendly name or description for the metrics for this
Rule. The name can contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 and minimum length one. It can't contain whitespace or metric names reserved for AWS WAF, including "All" and "Default_Action." You can't change the name of the metric after you create theRule.
iv_changetoken TYPE /AWS1/WAFCHANGETOKEN /AWS1/WAFCHANGETOKEN¶
The value returned by the most recent call to GetChangeToken.
Optional arguments:¶
it_tags TYPE /AWS1/CL_WAFTAG=>TT_TAGLIST TT_TAGLIST¶
RETURNING¶
oo_output TYPE REF TO /aws1/cl_wafcreateruleresponse /AWS1/CL_WAFCREATERULERESPONSE¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->createrule(
it_tags = VALUE /aws1/cl_waftag=>tt_taglist(
(
new /aws1/cl_waftag(
iv_key = |string|
iv_value = |string|
)
)
)
iv_changetoken = |string|
iv_metricname = |string|
iv_name = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lo_rule = lo_result->get_rule( ).
IF lo_rule IS NOT INITIAL.
lv_resourceid = lo_rule->get_ruleid( ).
lv_resourcename = lo_rule->get_name( ).
lv_metricname = lo_rule->get_metricname( ).
LOOP AT lo_rule->get_predicates( ) into lo_row.
lo_row_1 = lo_row.
IF lo_row_1 IS NOT INITIAL.
lv_negated = lo_row_1->get_negated( ).
lv_predicatetype = lo_row_1->get_type( ).
lv_resourceid = lo_row_1->get_dataid( ).
ENDIF.
ENDLOOP.
ENDIF.
lv_changetoken = lo_result->get_changetoken( ).
ENDIF.
To create a rule¶
The following example creates a rule named WAFByteHeaderRule.
DATA(lo_result) = lo_client->createrule(
iv_changetoken = |abcd12f2-46da-4fdb-b8d5-fbd4c466928f|
iv_metricname = |WAFByteHeaderRule|
iv_name = |WAFByteHeaderRule|
).