Skip to content

create_byte_match_set async

create_byte_match_set(
    name: ResourceName,
    change_token: ChangeToken,
    *,
    config_overrides: Optional[AsyncWAFRegionalClientConfig] = None,
) -> CreateByteMatchSetResponse

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 ByteMatchSet. You then use UpdateByteMatchSet to identify the part of a web request that you want AWS WAF to inspect, such as the values of the User-Agent header or the query string. For example, you can create a ByteMatchSet that matches any requests with User-Agent headers that contain the string BadBot. You can then configure AWS WAF to reject those requests.

To create and configure a ByteMatchSet, perform the following steps:

  1. Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of a CreateByteMatchSet request.

  2. Submit a CreateByteMatchSet request.

  3. Use GetChangeToken to get the change token that you provide in the ChangeToken parameter of an UpdateByteMatchSet request.

  4. Submit an UpdateByteMatchSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the value that you want AWS WAF to watch for.

For more information about how to use the AWS WAF API to allow or block HTTP requests, see the AWS WAF Developer Guide.

Parameters:

Raises:

  • 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, or WebACL) using an action other than INSERT or DELETE.

    • You tried to create a WebACL with a DefaultAction Type other than ALLOW, BLOCK, or COUNT.

    • You tried to create a RateBasedRule with a RateKey value other than IP.

    • You tried to update a WebACL with a WafAction Type other than ALLOW, BLOCK, or COUNT.

    • You tried to update a ByteMatchSet with a FieldToMatch Type other than HEADER, METHOD, QUERY_STRING, URI, or BODY.

    • You tried to update a ByteMatchSet with a Field of HEADER but no value for Data.

    • 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 WebACL objects 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.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_waf_regional/_services/async_waf_regional.py
async def create_byte_match_set(
    self,
    name: "capo_waf_regional.types.resource_name.ResourceName",
    change_token: "capo_waf_regional.types.change_token.ChangeToken",
    *,
    config_overrides: Optional[AsyncWAFRegionalClientConfig] = None,
) -> "capo_waf_regional.types.create_byte_match_set_response.CreateByteMatchSetResponse":
    """<note> <p>This is <b>AWS WAF Classic</b> documentation. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html">AWS WAF Classic</a> in the developer guide.</p> <p> <b>For the latest version of AWS WAF</b>, use the AWS WAFV2 API and see the <a href="https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html">AWS WAF Developer Guide</a>. With the latest version, AWS WAF has a single set of endpoints for regional and global use. </p> </note> <p>Creates a <code>ByteMatchSet</code>. You then use <a>UpdateByteMatchSet</a> to identify the part of a web request that you want AWS WAF to inspect, such as the values of the <code>User-Agent</code> header or the query string. For example, you can create a <code>ByteMatchSet</code> that matches any requests with <code>User-Agent</code> headers that contain the string <code>BadBot</code>. You can then configure AWS WAF to reject those requests.</p> <p>To create and configure a <code>ByteMatchSet</code>, perform the following steps:</p> <ol> <li> <p>Use <a>GetChangeToken</a> to get the change token that you provide in the <code>ChangeToken</code> parameter of a <code>CreateByteMatchSet</code> request.</p> </li> <li> <p>Submit a <code>CreateByteMatchSet</code> request.</p> </li> <li> <p>Use <code>GetChangeToken</code> to get the change token that you provide in the <code>ChangeToken</code> parameter of an <code>UpdateByteMatchSet</code> request.</p> </li> <li> <p>Submit an <a>UpdateByteMatchSet</a> request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the value that you want AWS WAF to watch for.</p> </li> </ol> <p>For more information about how to use the AWS WAF API to allow or block HTTP requests, see the <a href="https://docs.aws.amazon.com/waf/latest/developerguide/">AWS WAF Developer Guide</a>.</p>

    Args:
        name: <p>A friendly name or description of the <a>ByteMatchSet</a>. You can't change <code>Name</code> after you create a <code>ByteMatchSet</code>.</p>
        change_token: <p>The value returned by the most recent call to <a>GetChangeToken</a>.</p>

    Raises:
        capo_waf_regional.errors.waf_disallowed_name_exception.WAFDisallowedNameException: <p>The name specified is invalid.</p>
        capo_waf_regional.errors.waf_internal_error_exception.WAFInternalErrorException: <p>The operation failed because of a system problem, even though the request was valid. Retry your request.</p>
        capo_waf_regional.errors.waf_invalid_account_exception.WAFInvalidAccountException: <p>The operation failed because you tried to create, update, or delete an object by using an invalid account identifier.</p>
        capo_waf_regional.errors.waf_invalid_parameter_exception.WAFInvalidParameterException: <p>The operation failed because AWS WAF didn't recognize a parameter in the request. For example:</p> <ul> <li> <p>You specified an invalid parameter name.</p> </li> <li> <p>You specified an invalid value.</p> </li> <li> <p>You tried to update an object (<code>ByteMatchSet</code>, <code>IPSet</code>, <code>Rule</code>, or <code>WebACL</code>) using an action other than <code>INSERT</code> or <code>DELETE</code>.</p> </li> <li> <p>You tried to create a <code>WebACL</code> with a <code>DefaultAction</code> <code>Type</code> other than <code>ALLOW</code>, <code>BLOCK</code>, or <code>COUNT</code>.</p> </li> <li> <p>You tried to create a <code>RateBasedRule</code> with a <code>RateKey</code> value other than <code>IP</code>.</p> </li> <li> <p>You tried to update a <code>WebACL</code> with a <code>WafAction</code> <code>Type</code> other than <code>ALLOW</code>, <code>BLOCK</code>, or <code>COUNT</code>.</p> </li> <li> <p>You tried to update a <code>ByteMatchSet</code> with a <code>FieldToMatch</code> <code>Type</code> other than HEADER, METHOD, QUERY_STRING, URI, or BODY.</p> </li> <li> <p>You tried to update a <code>ByteMatchSet</code> with a <code>Field</code> of <code>HEADER</code> but no value for <code>Data</code>.</p> </li> <li> <p>Your request references an ARN that is malformed, or corresponds to a resource with which a web ACL cannot be associated.</p> </li> </ul>
        capo_waf_regional.errors.waf_limits_exceeded_exception.WAFLimitsExceededException: <p>The operation exceeds a resource limit, for example, the maximum number of <code>WebACL</code> objects that you can create for an AWS account. For more information, see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/limits.html">Limits</a> in the <i>AWS WAF Developer Guide</i>.</p>
        capo_waf_regional.errors.waf_stale_data_exception.WAFStaleDataException: <p>The operation failed because you tried to create, update, or delete an object by using a change token that has already been used.</p>
        capo_waf_regional.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_waf_regional.types.create_byte_match_set_request.CreateByteMatchSetRequest]",
    ) -> AsyncOperationResponse[
        "capo_waf_regional.types.create_byte_match_set_response.CreateByteMatchSetResponse"
    ]:
        import capo_waf_regional._operations.awswaf_regional_20161128.create_byte_match_set

        (
            output,
            http_response,
        ) = await capo_waf_regional._operations.awswaf_regional_20161128.create_byte_match_set.async_create_byte_match_set(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateByteMatchSet")
    )
    input_: capo_waf_regional.types.create_byte_match_set_request.CreateByteMatchSetRequest = {
        "name": name,
        "change_token": change_token,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output