create_web_acl
async
¶
create_web_acl(
name: ResourceName,
metric_name: MetricName,
default_action: WafAction,
change_token: ChangeToken,
*,
config_overrides: Optional[AsyncWAFClientConfig] = None,
tags: Optional[TagList] = None,
) -> CreateWebACLResponse
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 WebACL, which contains the Rules that identify the CloudFront web requests that you want to allow, block, or count. AWS WAF evaluates Rules in order based on the value of Priority for each Rule.
You also specify a default action, either ALLOW or BLOCK. If a web request doesn't match any of the Rules in a WebACL, AWS WAF responds to the request with the default action.
To create and configure a WebACL, perform the following steps:
-
Create and update the
ByteMatchSetobjects and other predicates that you want to include inRules. For more information, see CreateByteMatchSet, UpdateByteMatchSet, CreateIPSet, UpdateIPSet, CreateSqlInjectionMatchSet, and UpdateSqlInjectionMatchSet. -
Create and update the
Rulesthat you want to include in theWebACL. For more information, see CreateRule and UpdateRule. -
Use GetChangeToken to get the change token that you provide in the
ChangeTokenparameter of aCreateWebACLrequest. -
Submit a
CreateWebACLrequest. -
Use
GetChangeTokento get the change token that you provide in theChangeTokenparameter of an UpdateWebACL request. -
Submit an UpdateWebACL request to specify the
Rulesthat you want to include in theWebACL, to specify the default action, and to associate theWebACLwith a CloudFront distribution.
For more information about how to use the AWS WAF API, see the AWS WAF Developer Guide.
Parameters:
-
name(ResourceName) –A friendly name or description of the WebACL. You can't change
Nameafter you create theWebACL. -
metric_name(MetricName) –A friendly name or description for the metrics for this
WebACL.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 changeMetricNameafter you create theWebACL. -
default_action(WafAction) –The action that you want AWS WAF to take when a request doesn't match the criteria specified in any of the
Ruleobjects that are associated with theWebACL. -
change_token(ChangeToken) –The value returned by the most recent call to GetChangeToken.
-
tags(Optional[TagList], default:None) –
Raises:
-
WAFBadRequestException– -
WAFDisallowedNameException–The name specified is invalid.
-
WAFInternalErrorException–The operation failed because of a system problem, even though the request was valid. Retry your request.
-
WAFInvalidAccountException–The operation failed because you tried to create, update, or delete an object by using an invalid account identifier.
-
WAFInvalidParameterException–The operation failed because AWS WAF didn't recognize a parameter in the request. For example:
-
You specified an invalid parameter name.
-
You specified an invalid value.
-
You tried to update an object (
ByteMatchSet,IPSet,Rule, orWebACL) using an action other thanINSERTorDELETE. -
You tried to create a
WebACLwith aDefaultActionTypeother thanALLOW,BLOCK, orCOUNT. -
You tried to create a
RateBasedRulewith aRateKeyvalue other thanIP. -
You tried to update a
WebACLwith aWafActionTypeother thanALLOW,BLOCK, orCOUNT. -
You tried to update a
ByteMatchSetwith aFieldToMatchTypeother than HEADER, METHOD, QUERY_STRING, URI, or BODY. -
You tried to update a
ByteMatchSetwith aFieldofHEADERbut no value forData. -
Your request references an ARN that is malformed, or corresponds to a resource with which a web ACL cannot be associated.
-
-
WAFLimitsExceededException–The operation exceeds a resource limit, for example, the maximum number of
WebACLobjects that you can create for an AWS account. For more information, see Limits in the AWS WAF Developer Guide. -
WAFStaleDataException–The operation failed because you tried to create, update, or delete an object by using a change token that has already been used.
-
WAFTagOperationException– -
WAFTagOperationInternalErrorException– -
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create a web ACL The following example creates a web ACL named CreateExample.
>>> await client.create_web_acl(name='CreateExample', metric_name='CreateExample', default_action={'Type': 'ALLOW'}, change_token='abcd12f2-46da-4fdb-b8d5-fbd4c466928f')