You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::WAF::Client

Inherits:
Seahorse::Client::Base show all
Defined in:
(unknown)

Overview

An API client for AWS WAF. To construct a client, you need to configure a :region and :credentials.

waf = Aws::WAF::Client.new(
  region: region_name,
  credentials: credentials,
  # ...
)

See #initialize for a full list of supported configuration options.

Region

You can configure a default region in the following locations:

  • ENV['AWS_REGION']
  • Aws.config[:region]

Go here for a list of supported regions.

Credentials

Default credentials are loaded automatically from the following locations:

  • ENV['AWS_ACCESS_KEY_ID'] and ENV['AWS_SECRET_ACCESS_KEY']
  • Aws.config[:credentials]
  • The shared credentials ini file at ~/.aws/credentials (more information)
  • From an instance profile when running on EC2

You can also construct a credentials object from one of the following classes:

Alternatively, you configure credentials with :access_key_id and :secret_access_key:

# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))

Aws::WAF::Client.new(
  access_key_id: creds['access_key_id'],
  secret_access_key: creds['secret_access_key']
)

Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Base

#config, #handlers

Constructor collapse

API Operations collapse

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Base

add_plugin, api, #build_request, clear_plugins, define, new, #operation, #operation_names, plugins, remove_plugin, set_api, set_plugins

Methods included from Seahorse::Client::HandlerBuilder

#handle, #handle_request, #handle_response

Constructor Details

#initialize(options = {}) ⇒ Aws::WAF::Client

Constructs an API client.

Options Hash (options):

  • :access_key_id (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :convert_params (Boolean) — default: true

    When true, an attempt is made to coerce request parameters into the required types. See Plugins::ParamConverter for more details.

  • :credentials (required, Credentials)

    Your AWS credentials. The following locations will be searched in order for credentials:

    • :access_key_id, :secret_access_key, and :session_token options
    • ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
    • HOME/.aws/credentials shared credentials file
    • EC2 instance profile credentials See Plugins::RequestSigner for more details.
  • :endpoint (String)

    A default endpoint is constructed from the :region. See Plugins::RegionalEndpoint for more details.

  • :http_continue_timeout (Float) — default: 1

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_idle_timeout (Integer) — default: 5

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_open_timeout (Integer) — default: 15

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_proxy (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_read_timeout (Integer) — default: 60

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_wire_trace (Boolean) — default: false

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :log_level (Symbol) — default: :info

    The log level to send messages to the logger at. See Plugins::Logging for more details.

  • :log_formatter (Logging::LogFormatter)

    The log formatter. Defaults to Seahorse::Client::Logging::Formatter.default. See Plugins::Logging for more details.

  • :logger (Logger) — default: nil

    The Logger instance to send log messages to. If this option is not set, logging will be disabled. See Plugins::Logging for more details.

  • :profile (String)

    Used when loading credentials from the shared credentials file at HOME/.aws/credentials. When not specified, 'default' is used. See Plugins::RequestSigner for more details.

  • :raise_response_errors (Boolean) — default: true

    When true, response errors are raised. See Seahorse::Client::Plugins::RaiseResponseErrors for more details.

  • :region (required, String)

    The AWS region to connect to. The region is used to construct the client endpoint. Defaults to ENV['AWS_REGION']. Also checks AMAZON_REGION and AWS_DEFAULT_REGION. See Plugins::RegionalEndpoint for more details.

  • :retry_limit (Integer) — default: 3

    The maximum number of times to retry failed requests. Only ~ 500 level server errors and certain ~ 400 level client errors are retried. Generally, these are throttling errors, data checksum errors, networking errors, timeout errors and auth errors from expired credentials. See Plugins::RetryErrors for more details.

  • :secret_access_key (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :session_token (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :simple_json (Boolean) — default: false

    Disables request parameter conversion, validation, and formatting. Also disable response data type conversions. This option is useful when you want to ensure the highest level of performance by avoiding overhead of walking request parameters and response data structures.

    When :simple_json is enabled, the request parameters hash must be formatted exactly as the DynamoDB API expects. See Plugins::Protocols::JsonRpc for more details.

  • :ssl_ca_bundle (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_directory (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_store (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_verify_peer (Boolean) — default: true

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :stub_responses (Boolean) — default: false

    Causes the client to return stubbed responses. By default fake responses are generated and returned. You can specify the response data to return or errors to raise by calling ClientStubs#stub_responses. See ClientStubs for more information.

    Please note When response stubbing is enabled, no HTTP requests are made, and retries are disabled. See Plugins::StubResponses for more details.

  • :validate_params (Boolean) — default: true

    When true, request parameters are validated before sending the request. See Plugins::ParamValidator for more details.

Instance Method Details

#create_byte_match_set(options = {}) ⇒ Types::CreateByteMatchSetResponse

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.

Examples:

Request syntax with placeholder values


resp = client.create_byte_match_set({
  name: "ResourceName", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.byte_match_set.byte_match_set_id #=> String
resp.byte_match_set.name #=> String
resp.byte_match_set.byte_match_tuples #=> Array
resp.byte_match_set.byte_match_tuples[0].field_to_match.type #=> String, one of "URI", "QUERY_STRING", "HEADER", "METHOD", "BODY"
resp.byte_match_set.byte_match_tuples[0].field_to_match.data #=> String
resp.byte_match_set.byte_match_tuples[0].target_string #=> IO
resp.byte_match_set.byte_match_tuples[0].text_transformation #=> String, one of "NONE", "COMPRESS_WHITE_SPACE", "HTML_ENTITY_DECODE", "LOWERCASE", "CMD_LINE", "URL_DECODE"
resp.byte_match_set.byte_match_tuples[0].positional_constraint #=> String, one of "EXACTLY", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "CONTAINS_WORD"
resp.change_token #=> String

Options Hash (options):

  • :name (required, String)

    A friendly name or description of the ByteMatchSet. You can\'t change Name after you create a ByteMatchSet.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#create_geo_match_set(options = {}) ⇒ Types::CreateGeoMatchSetResponse

Creates an GeoMatchSet, which you use to specify which web requests you want to allow or block based on the country that the requests originate from. For example, if you're receiving a lot of requests from one or more countries and you want to block the requests, you can create an GeoMatchSet that contains those countries and then configure AWS WAF to block the requests.

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

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

  2. Submit a CreateGeoMatchSet request.

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

  4. Submit an UpdateGeoMatchSetSet request to specify the countries 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.

Examples:

Request syntax with placeholder values


resp = client.create_geo_match_set({
  name: "ResourceName", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.geo_match_set.geo_match_set_id #=> String
resp.geo_match_set.name #=> String
resp.geo_match_set.geo_match_constraints #=> Array
resp.geo_match_set.geo_match_constraints[0].type #=> String, one of "Country"
resp.geo_match_set.geo_match_constraints[0].value #=> String, one of "AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CW", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HM", "VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MP", "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "BL", "SH", "KN", "LC", "MF", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SX", "SK", "SI", "SB", "SO", "ZA", "GS", "SS", "ES", "LK", "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "US", "UM", "UY", "UZ", "VU", "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW"
resp.change_token #=> String

Options Hash (options):

  • :name (required, String)

    A friendly name or description of the GeoMatchSet. You can\'t change Name after you create the GeoMatchSet.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#create_ip_set(options = {}) ⇒ Types::CreateIPSetResponse

Creates an IPSet, which you use to specify which web requests you want to allow or block based on the IP addresses that the requests originate from. For example, if you're receiving a lot of requests from one or more individual IP addresses or one or more ranges of IP addresses and you want to block the requests, you can create an IPSet that contains those IP addresses and then configure AWS WAF to block the requests.

To create and configure an IPSet, perform the following steps:

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

  2. Submit a CreateIPSet request.

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

  4. Submit an UpdateIPSet request to specify the IP addresses 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.

Examples:

Example: To create an IP set


# The following example creates an IP match set named MyIPSetFriendlyName.

resp = client.create_ip_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  name: "MyIPSetFriendlyName", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  ip_set: {
    ip_set_descriptors: [
      {
        type: "IPV4", 
        value: "192.0.2.44/32", 
      }, 
    ], 
    ip_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
    name: "MyIPSetFriendlyName", 
  }, 
}

Request syntax with placeholder values


resp = client.create_ip_set({
  name: "ResourceName", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.ip_set.ip_set_id #=> String
resp.ip_set.name #=> String
resp.ip_set.ip_set_descriptors #=> Array
resp.ip_set.ip_set_descriptors[0].type #=> String, one of "IPV4", "IPV6"
resp.ip_set.ip_set_descriptors[0].value #=> String
resp.change_token #=> String

Options Hash (options):

  • :name (required, String)

    A friendly name or description of the IPSet. You can\'t change Name after you create the IPSet.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#create_rate_based_rule(options = {}) ⇒ Types::CreateRateBasedRuleResponse

Creates a RateBasedRule. The RateBasedRule contains a RateLimit, which specifies the maximum number of requests that AWS WAF allows from a specified IP address in a five-minute period. The RateBasedRule also contains the IPSet objects, ByteMatchSet objects, and other predicates that identify the requests that you want to count or block if these requests exceed the RateLimit.

If you add more than one predicate to a RateBasedRule, a request not only must exceed the RateLimit, but it also must match all the specifications to be counted or blocked. For example, suppose you add the following to a RateBasedRule:

  • An IPSet that matches the IP address 192.0.2.44/32

  • A ByteMatchSet that matches BadBot in the User-Agent header

Further, you specify a RateLimit of 15,000.

You then add the RateBasedRule to a WebACL and specify that you want to block requests that meet the conditions in 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. Further, requests that match these two conditions must be received at a rate of more than 15,000 requests every five minutes. If both conditions are met and the rate is exceeded, AWS WAF blocks the requests. If the rate drops below 15,000 for a five-minute period, AWS WAF no longer blocks the requests.

As a second example, suppose you want to limit requests to a particular page on your site. To do this, you could add the following to a RateBasedRule:

  • A ByteMatchSet with FieldToMatch of URI

  • A PositionalConstraint of STARTS_WITH

  • A TargetString of login

Further, you specify a RateLimit of 15,000.

By adding this RateBasedRule to a WebACL, you could limit requests to your login page without affecting the rest of your site.

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

  1. Create and update the predicates that you want to include in the rule. For more information, see CreateByteMatchSet, CreateIPSet, and CreateSqlInjectionMatchSet.

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

  3. Submit a CreateRateBasedRule request.

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

  5. Submit an UpdateRateBasedRule request to specify the predicates that you want to include in the rule.

  6. Create and update a WebACL that contains the RateBasedRule. 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.

Examples:

Request syntax with placeholder values


resp = client.create_rate_based_rule({
  name: "ResourceName", # required
  metric_name: "MetricName", # required
  rate_key: "IP", # required, accepts IP
  rate_limit: 1, # required
  change_token: "ChangeToken", # required
})

Response structure


resp.rule.rule_id #=> String
resp.rule.name #=> String
resp.rule.metric_name #=> String
resp.rule.match_predicates #=> Array
resp.rule.match_predicates[0].negated #=> true/false
resp.rule.match_predicates[0].type #=> String, one of "IPMatch", "ByteMatch", "SqlInjectionMatch", "GeoMatch", "SizeConstraint", "XssMatch", "RegexMatch"
resp.rule.match_predicates[0].data_id #=> String
resp.rule.rate_key #=> String, one of "IP"
resp.rule.rate_limit #=> Integer
resp.change_token #=> String

Options Hash (options):

  • :name (required, String)

    A friendly name or description of the RateBasedRule. You can\'t change the name of a RateBasedRule after you create it.

  • :metric_name (required, String)

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

  • :rate_key (required, String)

    The field that AWS WAF uses to determine if requests are likely arriving from a single source and thus subject to rate monitoring. The only valid value for RateKey is IP. IP indicates that requests that arrive from the same IP address are subject to the RateLimit that is specified in the RateBasedRule.

  • :rate_limit (required, Integer)

    The maximum number of requests, which have an identical value in the field that is specified by RateKey, allowed in a five-minute period. If the number of requests exceeds the RateLimit and the other predicates specified in the rule are also met, AWS WAF triggers the action that is specified for this rule.

  • :change_token (required, String)

    The ChangeToken that you used to submit the CreateRateBasedRule request. You can also use this value to query the status of the request. For more information, see GetChangeTokenStatus.

Returns:

See Also:

#create_regex_match_set(options = {}) ⇒ Types::CreateRegexMatchSetResponse

Creates a RegexMatchSet. You then use UpdateRegexMatchSet 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 RegexMatchSet that contains a RegexMatchTuple that looks for any requests with User-Agent headers that match a RegexPatternSet with pattern B[a@]dB[o0]t. You can then configure AWS WAF to reject those requests.

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

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

  2. Submit a CreateRegexMatchSet request.

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

  4. Submit an UpdateRegexMatchSet 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, using a RegexPatternSet, 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.

Examples:

Request syntax with placeholder values


resp = client.create_regex_match_set({
  name: "ResourceName", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.regex_match_set.regex_match_set_id #=> String
resp.regex_match_set.name #=> String
resp.regex_match_set.regex_match_tuples #=> Array
resp.regex_match_set.regex_match_tuples[0].field_to_match.type #=> String, one of "URI", "QUERY_STRING", "HEADER", "METHOD", "BODY"
resp.regex_match_set.regex_match_tuples[0].field_to_match.data #=> String
resp.regex_match_set.regex_match_tuples[0].text_transformation #=> String, one of "NONE", "COMPRESS_WHITE_SPACE", "HTML_ENTITY_DECODE", "LOWERCASE", "CMD_LINE", "URL_DECODE"
resp.regex_match_set.regex_match_tuples[0].regex_pattern_set_id #=> String
resp.change_token #=> String

Options Hash (options):

  • :name (required, String)

    A friendly name or description of the RegexMatchSet. You can\'t change Name after you create a RegexMatchSet.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#create_regex_pattern_set(options = {}) ⇒ Types::CreateRegexPatternSetResponse

Creates a RegexPatternSet. You then use UpdateRegexPatternSet to specify the regular expression (regex) pattern that you want AWS WAF to search for, such as B[a@]dB[o0]t. You can then configure AWS WAF to reject those requests.

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

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

  2. Submit a CreateRegexPatternSet request.

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

  4. Submit an UpdateRegexPatternSet request to specify the string 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.

Examples:

Request syntax with placeholder values


resp = client.create_regex_pattern_set({
  name: "ResourceName", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.regex_pattern_set.regex_pattern_set_id #=> String
resp.regex_pattern_set.name #=> String
resp.regex_pattern_set.regex_pattern_strings #=> Array
resp.regex_pattern_set.regex_pattern_strings[0] #=> String
resp.change_token #=> String

Options Hash (options):

  • :name (required, String)

    A friendly name or description of the RegexPatternSet. You can\'t change Name after you create a RegexPatternSet.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#create_rule(options = {}) ⇒ Types::CreateRuleResponse

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 you add the following to a Rule:

  • An IPSet that matches the IP address 192.0.2.44/32

  • A ByteMatchSet that matches BadBot in the User-Agent header

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:

  1. Create and update the predicates that you want to include in the Rule. For more information, see CreateByteMatchSet, CreateIPSet, and CreateSqlInjectionMatchSet.

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

  3. Submit a CreateRule request.

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

  5. Submit an UpdateRule request to specify the predicates that you want to include in the Rule.

  6. Create and update a WebACL that contains the Rule. 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.

Examples:

Example: To create a rule


# The following example creates a rule named WAFByteHeaderRule.

resp = client.create_rule({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  metric_name: "WAFByteHeaderRule", 
  name: "WAFByteHeaderRule", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  rule: {
    metric_name: "WAFByteHeaderRule", 
    name: "WAFByteHeaderRule", 
    predicates: [
      {
        data_id: "MyByteMatchSetID", 
        negated: false, 
        type: "ByteMatch", 
      }, 
    ], 
    rule_id: "WAFRule-1-Example", 
  }, 
}

Request syntax with placeholder values


resp = client.create_rule({
  name: "ResourceName", # required
  metric_name: "MetricName", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.rule.rule_id #=> String
resp.rule.name #=> String
resp.rule.metric_name #=> String
resp.rule.predicates #=> Array
resp.rule.predicates[0].negated #=> true/false
resp.rule.predicates[0].type #=> String, one of "IPMatch", "ByteMatch", "SqlInjectionMatch", "GeoMatch", "SizeConstraint", "XssMatch", "RegexMatch"
resp.rule.predicates[0].data_id #=> String
resp.change_token #=> String

Options Hash (options):

  • :name (required, String)

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

  • :metric_name (required, 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 the name of the metric after you create the Rule.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#create_size_constraint_set(options = {}) ⇒ Types::CreateSizeConstraintSetResponse

Creates a SizeConstraintSet. You then use UpdateSizeConstraintSet to identify the part of a web request that you want AWS WAF to check for length, such as the length of the User-Agent header or the length of the query string. For example, you can create a SizeConstraintSet that matches any requests that have a query string that is longer than 100 bytes. You can then configure AWS WAF to reject those requests.

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

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

  2. Submit a CreateSizeConstraintSet request.

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

  4. Submit an UpdateSizeConstraintSet 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.

Examples:

Example: To create a size constraint


# The following example creates size constraint set named MySampleSizeConstraintSet.

resp = client.create_size_constraint_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  name: "MySampleSizeConstraintSet", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  size_constraint_set: {
    name: "MySampleSizeConstraintSet", 
    size_constraint_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
    size_constraints: [
      {
        comparison_operator: "GT", 
        field_to_match: {
          type: "QUERY_STRING", 
        }, 
        size: 0, 
        text_transformation: "NONE", 
      }, 
    ], 
  }, 
}

Request syntax with placeholder values


resp = client.create_size_constraint_set({
  name: "ResourceName", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.size_constraint_set.size_constraint_set_id #=> String
resp.size_constraint_set.name #=> String
resp.size_constraint_set.size_constraints #=> Array
resp.size_constraint_set.size_constraints[0].field_to_match.type #=> String, one of "URI", "QUERY_STRING", "HEADER", "METHOD", "BODY"
resp.size_constraint_set.size_constraints[0].field_to_match.data #=> String
resp.size_constraint_set.size_constraints[0].text_transformation #=> String, one of "NONE", "COMPRESS_WHITE_SPACE", "HTML_ENTITY_DECODE", "LOWERCASE", "CMD_LINE", "URL_DECODE"
resp.size_constraint_set.size_constraints[0].comparison_operator #=> String, one of "EQ", "NE", "LE", "LT", "GE", "GT"
resp.size_constraint_set.size_constraints[0].size #=> Integer
resp.change_token #=> String

Options Hash (options):

  • :name (required, String)

    A friendly name or description of the SizeConstraintSet. You can\'t change Name after you create a SizeConstraintSet.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#create_sql_injection_match_set(options = {}) ⇒ Types::CreateSqlInjectionMatchSetResponse

Creates a SqlInjectionMatchSet, which you use to allow, block, or count requests that contain snippets of SQL code in a specified part of web requests. AWS WAF searches for character sequences that are likely to be malicious strings.

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

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

  2. Submit a CreateSqlInjectionMatchSet request.

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

  4. Submit an UpdateSqlInjectionMatchSet request to specify the parts of web requests in which you want to allow, block, or count malicious SQL code.

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

Examples:

Example: To create a SQL injection match set


# The following example creates a SQL injection match set named MySQLInjectionMatchSet.

resp = client.create_sql_injection_match_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  name: "MySQLInjectionMatchSet", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  sql_injection_match_set: {
    name: "MySQLInjectionMatchSet", 
    sql_injection_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
    sql_injection_match_tuples: [
      {
        field_to_match: {
          type: "QUERY_STRING", 
        }, 
        text_transformation: "URL_DECODE", 
      }, 
    ], 
  }, 
}

Request syntax with placeholder values


resp = client.create_sql_injection_match_set({
  name: "ResourceName", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.sql_injection_match_set.sql_injection_match_set_id #=> String
resp.sql_injection_match_set.name #=> String
resp.sql_injection_match_set.sql_injection_match_tuples #=> Array
resp.sql_injection_match_set.sql_injection_match_tuples[0].field_to_match.type #=> String, one of "URI", "QUERY_STRING", "HEADER", "METHOD", "BODY"
resp.sql_injection_match_set.sql_injection_match_tuples[0].field_to_match.data #=> String
resp.sql_injection_match_set.sql_injection_match_tuples[0].text_transformation #=> String, one of "NONE", "COMPRESS_WHITE_SPACE", "HTML_ENTITY_DECODE", "LOWERCASE", "CMD_LINE", "URL_DECODE"
resp.change_token #=> String

Options Hash (options):

  • :name (required, String)

    A friendly name or description for the SqlInjectionMatchSet that you\'re creating. You can\'t change Name after you create the SqlInjectionMatchSet.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#create_web_acl(options = {}) ⇒ Types::CreateWebACLResponse

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:

  1. Create and update the ByteMatchSet objects and other predicates that you want to include in Rules. For more information, see CreateByteMatchSet, UpdateByteMatchSet, CreateIPSet, UpdateIPSet, CreateSqlInjectionMatchSet, and UpdateSqlInjectionMatchSet.

  2. Create and update the Rules that you want to include in the WebACL. For more information, see CreateRule and UpdateRule.

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

  4. Submit a CreateWebACL request.

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

  6. Submit an UpdateWebACL request to specify the Rules that you want to include in the WebACL, to specify the default action, and to associate the WebACL with a CloudFront distribution.

For more information about how to use the AWS WAF API, see the AWS WAF Developer Guide.

Examples:

Example: To create a web ACL


# The following example creates a web ACL named CreateExample.

resp = client.create_web_acl({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  default_action: {
    type: "ALLOW", 
  }, 
  metric_name: "CreateExample", 
  name: "CreateExample", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  web_acl: {
    default_action: {
      type: "ALLOW", 
    }, 
    metric_name: "CreateExample", 
    name: "CreateExample", 
    rules: [
      {
        action: {
          type: "ALLOW", 
        }, 
        priority: 1, 
        rule_id: "WAFRule-1-Example", 
      }, 
    ], 
    web_acl_id: "example-46da-4444-5555-example", 
  }, 
}

Request syntax with placeholder values


resp = client.create_web_acl({
  name: "ResourceName", # required
  metric_name: "MetricName", # required
  default_action: { # required
    type: "BLOCK", # required, accepts BLOCK, ALLOW, COUNT
  },
  change_token: "ChangeToken", # required
})

Response structure


resp.web_acl.web_acl_id #=> String
resp.web_acl.name #=> String
resp.web_acl.metric_name #=> String
resp.web_acl.default_action.type #=> String, one of "BLOCK", "ALLOW", "COUNT"
resp.web_acl.rules #=> Array
resp.web_acl.rules[0].priority #=> Integer
resp.web_acl.rules[0].rule_id #=> String
resp.web_acl.rules[0].action.type #=> String, one of "BLOCK", "ALLOW", "COUNT"
resp.web_acl.rules[0].type #=> String, one of "REGULAR", "RATE_BASED"
resp.change_token #=> String

Options Hash (options):

  • :name (required, String)

    A friendly name or description of the WebACL. You can\'t change Name after you create the WebACL.

  • :metric_name (required, String)

    A friendly name or description for the metrics for this WebACL. 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 WebACL.

  • :default_action (required, Types::WafAction)

    The action that you want AWS WAF to take when a request doesn\'t match the criteria specified in any of the Rule objects that are associated with the WebACL.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#create_xss_match_set(options = {}) ⇒ Types::CreateXssMatchSetResponse

Creates an XssMatchSet, which you use to allow, block, or count requests that contain cross-site scripting attacks in the specified part of web requests. AWS WAF searches for character sequences that are likely to be malicious strings.

To create and configure an XssMatchSet, perform the following steps:

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

  2. Submit a CreateXssMatchSet request.

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

  4. Submit an UpdateXssMatchSet request to specify the parts of web requests in which you want to allow, block, or count cross-site scripting attacks.

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

Examples:

Example: To create an XSS match set


# The following example creates an XSS match set named MySampleXssMatchSet.

resp = client.create_xss_match_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  name: "MySampleXssMatchSet", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  xss_match_set: {
    name: "MySampleXssMatchSet", 
    xss_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
    xss_match_tuples: [
      {
        field_to_match: {
          type: "QUERY_STRING", 
        }, 
        text_transformation: "URL_DECODE", 
      }, 
    ], 
  }, 
}

Request syntax with placeholder values


resp = client.create_xss_match_set({
  name: "ResourceName", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.xss_match_set.xss_match_set_id #=> String
resp.xss_match_set.name #=> String
resp.xss_match_set.xss_match_tuples #=> Array
resp.xss_match_set.xss_match_tuples[0].field_to_match.type #=> String, one of "URI", "QUERY_STRING", "HEADER", "METHOD", "BODY"
resp.xss_match_set.xss_match_tuples[0].field_to_match.data #=> String
resp.xss_match_set.xss_match_tuples[0].text_transformation #=> String, one of "NONE", "COMPRESS_WHITE_SPACE", "HTML_ENTITY_DECODE", "LOWERCASE", "CMD_LINE", "URL_DECODE"
resp.change_token #=> String

Options Hash (options):

  • :name (required, String)

    A friendly name or description for the XssMatchSet that you\'re creating. You can\'t change Name after you create the XssMatchSet.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#delete_byte_match_set(options = {}) ⇒ Types::DeleteByteMatchSetResponse

Permanently deletes a ByteMatchSet. You can't delete a ByteMatchSet if it's still used in any Rules or if it still includes any ByteMatchTuple objects (any filters).

If you just want to remove a ByteMatchSet from a Rule, use UpdateRule.

To permanently delete a ByteMatchSet, perform the following steps:

  1. Update the ByteMatchSet to remove filters, if any. For more information, see UpdateByteMatchSet.

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

  3. Submit a DeleteByteMatchSet request.

Examples:

Example: To delete a byte match set


# The following example deletes a byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.delete_byte_match_set({
  byte_match_set_id: "exampleIDs3t-46da-4fdb-b8d5-abc321j569j5", 
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.delete_byte_match_set({
  byte_match_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#delete_geo_match_set(options = {}) ⇒ Types::DeleteGeoMatchSetResponse

Permanently deletes a GeoMatchSet. You can't delete a GeoMatchSet if it's still used in any Rules or if it still includes any countries.

If you just want to remove a GeoMatchSet from a Rule, use UpdateRule.

To permanently delete a GeoMatchSet from AWS WAF, perform the following steps:

  1. Update the GeoMatchSet to remove any countries. For more information, see UpdateGeoMatchSet.

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

  3. Submit a DeleteGeoMatchSet request.

Examples:

Request syntax with placeholder values


resp = client.delete_geo_match_set({
  geo_match_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#delete_ip_set(options = {}) ⇒ Types::DeleteIPSetResponse

Permanently deletes an IPSet. You can't delete an IPSet if it's still used in any Rules or if it still includes any IP addresses.

If you just want to remove an IPSet from a Rule, use UpdateRule.

To permanently delete an IPSet from AWS WAF, perform the following steps:

  1. Update the IPSet to remove IP address ranges, if any. For more information, see UpdateIPSet.

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

  3. Submit a DeleteIPSet request.

Examples:

Example: To delete an IP set


# The following example deletes an IP match set  with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.delete_ip_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  ip_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.delete_ip_set({
  ip_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

  • :ip_set_id (required, String)

    The IPSetId of the IPSet that you want to delete. IPSetId is returned by CreateIPSet and by ListIPSets.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#delete_rate_based_rule(options = {}) ⇒ Types::DeleteRateBasedRuleResponse

Permanently deletes a RateBasedRule. You can't delete a rule if it's still used in any WebACL objects or if it still includes any predicates, such as ByteMatchSet objects.

If you just want to remove a rule from a WebACL, use UpdateWebACL.

To permanently delete a RateBasedRule from AWS WAF, perform the following steps:

  1. Update the RateBasedRule to remove predicates, if any. For more information, see UpdateRateBasedRule.

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

  3. Submit a DeleteRateBasedRule request.

Examples:

Request syntax with placeholder values


resp = client.delete_rate_based_rule({
  rule_id: "ResourceId", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#delete_regex_match_set(options = {}) ⇒ Types::DeleteRegexMatchSetResponse

Permanently deletes a RegexMatchSet. You can't delete a RegexMatchSet if it's still used in any Rules or if it still includes any RegexMatchTuples objects (any filters).

If you just want to remove a RegexMatchSet from a Rule, use UpdateRule.

To permanently delete a RegexMatchSet, perform the following steps:

  1. Update the RegexMatchSet to remove filters, if any. For more information, see UpdateRegexMatchSet.

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

  3. Submit a DeleteRegexMatchSet request.

Examples:

Request syntax with placeholder values


resp = client.delete_regex_match_set({
  regex_match_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#delete_regex_pattern_set(options = {}) ⇒ Types::DeleteRegexPatternSetResponse

Permanently deletes a RegexPatternSet. You can't delete a RegexPatternSet if it's still used in any RegexMatchSet or if the RegexPatternSet is not empty.

Examples:

Request syntax with placeholder values


resp = client.delete_regex_pattern_set({
  regex_pattern_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#delete_rule(options = {}) ⇒ Types::DeleteRuleResponse

Permanently deletes a Rule. You can't delete a Rule if it's still used in any WebACL objects or if it still includes any predicates, such as ByteMatchSet objects.

If you just want to remove a Rule from a WebACL, use UpdateWebACL.

To permanently delete a Rule from AWS WAF, perform the following steps:

  1. Update the Rule to remove predicates, if any. For more information, see UpdateRule.

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

  3. Submit a DeleteRule request.

Examples:

Example: To delete a rule


# The following example deletes a rule with the ID WAFRule-1-Example.

resp = client.delete_rule({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  rule_id: "WAFRule-1-Example", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.delete_rule({
  rule_id: "ResourceId", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

  • :rule_id (required, String)

    The RuleId of the Rule that you want to delete. RuleId is returned by CreateRule and by ListRules.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#delete_size_constraint_set(options = {}) ⇒ Types::DeleteSizeConstraintSetResponse

Permanently deletes a SizeConstraintSet. You can't delete a SizeConstraintSet if it's still used in any Rules or if it still includes any SizeConstraint objects (any filters).

If you just want to remove a SizeConstraintSet from a Rule, use UpdateRule.

To permanently delete a SizeConstraintSet, perform the following steps:

  1. Update the SizeConstraintSet to remove filters, if any. For more information, see UpdateSizeConstraintSet.

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

  3. Submit a DeleteSizeConstraintSet request.

Examples:

Example: To delete a size constraint set


# The following example deletes a size constraint set  with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.delete_size_constraint_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  size_constraint_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.delete_size_constraint_set({
  size_constraint_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#delete_sql_injection_match_set(options = {}) ⇒ Types::DeleteSqlInjectionMatchSetResponse

Permanently deletes a SqlInjectionMatchSet. You can't delete a SqlInjectionMatchSet if it's still used in any Rules or if it still contains any SqlInjectionMatchTuple objects.

If you just want to remove a SqlInjectionMatchSet from a Rule, use UpdateRule.

To permanently delete a SqlInjectionMatchSet from AWS WAF, perform the following steps:

  1. Update the SqlInjectionMatchSet to remove filters, if any. For more information, see UpdateSqlInjectionMatchSet.

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

  3. Submit a DeleteSqlInjectionMatchSet request.

Examples:

Example: To delete a SQL injection match set


# The following example deletes a SQL injection match set  with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.delete_sql_injection_match_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  sql_injection_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.delete_sql_injection_match_set({
  sql_injection_match_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#delete_web_acl(options = {}) ⇒ Types::DeleteWebACLResponse

Permanently deletes a WebACL. You can't delete a WebACL if it still contains any Rules.

To delete a WebACL, perform the following steps:

  1. Update the WebACL to remove Rules, if any. For more information, see UpdateWebACL.

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

  3. Submit a DeleteWebACL request.

Examples:

Example: To delete a web ACL


# The following example deletes a web ACL with the ID example-46da-4444-5555-example.

resp = client.delete_web_acl({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  web_acl_id: "example-46da-4444-5555-example", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.delete_web_acl({
  web_acl_id: "ResourceId", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

  • :web_acl_id (required, String)

    The WebACLId of the WebACL that you want to delete. WebACLId is returned by CreateWebACL and by ListWebACLs.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

Returns:

See Also:

#delete_xss_match_set(options = {}) ⇒ Types::DeleteXssMatchSetResponse

Permanently deletes an XssMatchSet. You can't delete an XssMatchSet if it's still used in any Rules or if it still contains any XssMatchTuple objects.

If you just want to remove an XssMatchSet from a Rule, use UpdateRule.

To permanently delete an XssMatchSet from AWS WAF, perform the following steps:

  1. Update the XssMatchSet to remove filters, if any. For more information, see UpdateXssMatchSet.

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

  3. Submit a DeleteXssMatchSet request.

Examples:

Example: To delete an XSS match set


# The following example deletes an XSS match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.delete_xss_match_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  xss_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.delete_xss_match_set({
  xss_match_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#get_byte_match_set(options = {}) ⇒ Types::GetByteMatchSetResponse

Returns the ByteMatchSet specified by ByteMatchSetId.

Examples:

Example: To get a byte match set


# The following example returns the details of a byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.get_byte_match_set({
  byte_match_set_id: "exampleIDs3t-46da-4fdb-b8d5-abc321j569j5", 
})

# resp.to_h outputs the following:
{
  byte_match_set: {
    byte_match_set_id: "exampleIDs3t-46da-4fdb-b8d5-abc321j569j5", 
    byte_match_tuples: [
      {
        field_to_match: {
          data: "referer", 
          type: "HEADER", 
        }, 
        positional_constraint: "CONTAINS", 
        target_string: "badrefer1", 
        text_transformation: "NONE", 
      }, 
    ], 
    name: "ByteMatchNameExample", 
  }, 
}

Request syntax with placeholder values


resp = client.get_byte_match_set({
  byte_match_set_id: "ResourceId", # required
})

Response structure


resp.byte_match_set.byte_match_set_id #=> String
resp.byte_match_set.name #=> String
resp.byte_match_set.byte_match_tuples #=> Array
resp.byte_match_set.byte_match_tuples[0].field_to_match.type #=> String, one of "URI", "QUERY_STRING", "HEADER", "METHOD", "BODY"
resp.byte_match_set.byte_match_tuples[0].field_to_match.data #=> String
resp.byte_match_set.byte_match_tuples[0].target_string #=> IO
resp.byte_match_set.byte_match_tuples[0].text_transformation #=> String, one of "NONE", "COMPRESS_WHITE_SPACE", "HTML_ENTITY_DECODE", "LOWERCASE", "CMD_LINE", "URL_DECODE"
resp.byte_match_set.byte_match_tuples[0].positional_constraint #=> String, one of "EXACTLY", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "CONTAINS_WORD"

Options Hash (options):

Returns:

See Also:

#get_change_token(options = {}) ⇒ Types::GetChangeTokenResponse

When you want to create, update, or delete AWS WAF objects, get a change token and include the change token in the create, update, or delete request. Change tokens ensure that your application doesn't submit conflicting requests to AWS WAF.

Each create, update, or delete request must use a unique change token. If your application submits a GetChangeToken request and then submits a second GetChangeToken request before submitting a create, update, or delete request, the second GetChangeToken request returns the same value as the first GetChangeToken request.

When you use a change token in a create, update, or delete request, the status of the change token changes to PENDING, which indicates that AWS WAF is propagating the change to all AWS WAF servers. Use GetChangeTokenStatus to determine the status of your change token.

Examples:

Example: To get a change token


# The following example returns a change token to use for a create, update or delete operation.

resp = client.get_change_token({
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.get_change_token()

Response structure


resp.change_token #=> String

Returns:

See Also:

#get_change_token_status(options = {}) ⇒ Types::GetChangeTokenStatusResponse

Returns the status of a ChangeToken that you got by calling GetChangeToken. ChangeTokenStatus is one of the following values:

  • PROVISIONED: You requested the change token by calling GetChangeToken, but you haven't used it yet in a call to create, update, or delete an AWS WAF object.

  • PENDING: AWS WAF is propagating the create, update, or delete request to all AWS WAF servers.

  • IN_SYNC: Propagation is complete.

Examples:

Example: To get the change token status


# The following example returns the status of a change token with the ID abcd12f2-46da-4fdb-b8d5-fbd4c466928f.

resp = client.get_change_token_status({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
})

# resp.to_h outputs the following:
{
  change_token_status: "PENDING", 
}

Request syntax with placeholder values


resp = client.get_change_token_status({
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token_status #=> String, one of "PROVISIONED", "PENDING", "INSYNC"

Options Hash (options):

  • :change_token (required, String)

    The change token for which you want to get the status. This change token was previously returned in the GetChangeToken response.

Returns:

See Also:

#get_geo_match_set(options = {}) ⇒ Types::GetGeoMatchSetResponse

Returns the GeoMatchSet that is specified by GeoMatchSetId.

Examples:

Request syntax with placeholder values


resp = client.get_geo_match_set({
  geo_match_set_id: "ResourceId", # required
})

Response structure


resp.geo_match_set.geo_match_set_id #=> String
resp.geo_match_set.name #=> String
resp.geo_match_set.geo_match_constraints #=> Array
resp.geo_match_set.geo_match_constraints[0].type #=> String, one of "Country"
resp.geo_match_set.geo_match_constraints[0].value #=> String, one of "AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CW", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HM", "VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MP", "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "BL", "SH", "KN", "LC", "MF", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SX", "SK", "SI", "SB", "SO", "ZA", "GS", "SS", "ES", "LK", "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "US", "UM", "UY", "UZ", "VU", "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW"

Options Hash (options):

Returns:

See Also:

#get_ip_set(options = {}) ⇒ Types::GetIPSetResponse

Returns the IPSet that is specified by IPSetId.

Examples:

Example: To get an IP set


# The following example returns the details of an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.get_ip_set({
  ip_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
})

# resp.to_h outputs the following:
{
  ip_set: {
    ip_set_descriptors: [
      {
        type: "IPV4", 
        value: "192.0.2.44/32", 
      }, 
    ], 
    ip_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
    name: "MyIPSetFriendlyName", 
  }, 
}

Request syntax with placeholder values


resp = client.get_ip_set({
  ip_set_id: "ResourceId", # required
})

Response structure


resp.ip_set.ip_set_id #=> String
resp.ip_set.name #=> String
resp.ip_set.ip_set_descriptors #=> Array
resp.ip_set.ip_set_descriptors[0].type #=> String, one of "IPV4", "IPV6"
resp.ip_set.ip_set_descriptors[0].value #=> String

Options Hash (options):

  • :ip_set_id (required, String)

    The IPSetId of the IPSet that you want to get. IPSetId is returned by CreateIPSet and by ListIPSets.

Returns:

See Also:

#get_rate_based_rule(options = {}) ⇒ Types::GetRateBasedRuleResponse

Returns the RateBasedRule that is specified by the RuleId that you included in the GetRateBasedRule request.

Examples:

Request syntax with placeholder values


resp = client.get_rate_based_rule({
  rule_id: "ResourceId", # required
})

Response structure


resp.rule.rule_id #=> String
resp.rule.name #=> String
resp.rule.metric_name #=> String
resp.rule.match_predicates #=> Array
resp.rule.match_predicates[0].negated #=> true/false
resp.rule.match_predicates[0].type #=> String, one of "IPMatch", "ByteMatch", "SqlInjectionMatch", "GeoMatch", "SizeConstraint", "XssMatch", "RegexMatch"
resp.rule.match_predicates[0].data_id #=> String
resp.rule.rate_key #=> String, one of "IP"
resp.rule.rate_limit #=> Integer

Options Hash (options):

Returns:

See Also:

#get_rate_based_rule_managed_keys(options = {}) ⇒ Types::GetRateBasedRuleManagedKeysResponse

Returns an array of IP addresses currently being blocked by the RateBasedRule that is specified by the RuleId. The maximum number of managed keys that will be blocked is 10,000. If more than 10,000 addresses exceed the rate limit, the 10,000 addresses with the highest rates will be blocked.

Examples:

Request syntax with placeholder values


resp = client.get_rate_based_rule_managed_keys({
  rule_id: "ResourceId", # required
  next_marker: "NextMarker",
})

Response structure


resp.managed_keys #=> Array
resp.managed_keys[0] #=> String
resp.next_marker #=> String

Options Hash (options):

  • :rule_id (required, String)

    The RuleId of the RateBasedRule for which you want to get a list of ManagedKeys. RuleId is returned by CreateRateBasedRule and by ListRateBasedRules.

  • :next_marker (String)

    A null value and not currently used. Do not include this in your request.

Returns:

See Also:

#get_regex_match_set(options = {}) ⇒ Types::GetRegexMatchSetResponse

Returns the RegexMatchSet specified by RegexMatchSetId.

Examples:

Request syntax with placeholder values


resp = client.get_regex_match_set({
  regex_match_set_id: "ResourceId", # required
})

Response structure


resp.regex_match_set.regex_match_set_id #=> String
resp.regex_match_set.name #=> String
resp.regex_match_set.regex_match_tuples #=> Array
resp.regex_match_set.regex_match_tuples[0].field_to_match.type #=> String, one of "URI", "QUERY_STRING", "HEADER", "METHOD", "BODY"
resp.regex_match_set.regex_match_tuples[0].field_to_match.data #=> String
resp.regex_match_set.regex_match_tuples[0].text_transformation #=> String, one of "NONE", "COMPRESS_WHITE_SPACE", "HTML_ENTITY_DECODE", "LOWERCASE", "CMD_LINE", "URL_DECODE"
resp.regex_match_set.regex_match_tuples[0].regex_pattern_set_id #=> String

Options Hash (options):

Returns:

See Also:

#get_regex_pattern_set(options = {}) ⇒ Types::GetRegexPatternSetResponse

Returns the RegexPatternSet specified by RegexPatternSetId.

Examples:

Request syntax with placeholder values


resp = client.get_regex_pattern_set({
  regex_pattern_set_id: "ResourceId", # required
})

Response structure


resp.regex_pattern_set.regex_pattern_set_id #=> String
resp.regex_pattern_set.name #=> String
resp.regex_pattern_set.regex_pattern_strings #=> Array
resp.regex_pattern_set.regex_pattern_strings[0] #=> String

Options Hash (options):

Returns:

See Also:

#get_rule(options = {}) ⇒ Types::GetRuleResponse

Returns the Rule that is specified by the RuleId that you included in the GetRule request.

Examples:

Example: To get a rule


# The following example returns the details of a rule with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.get_rule({
  rule_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
})

# resp.to_h outputs the following:
{
  rule: {
    metric_name: "WAFByteHeaderRule", 
    name: "WAFByteHeaderRule", 
    predicates: [
      {
        data_id: "MyByteMatchSetID", 
        negated: false, 
        type: "ByteMatch", 
      }, 
    ], 
    rule_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
  }, 
}

Request syntax with placeholder values


resp = client.get_rule({
  rule_id: "ResourceId", # required
})

Response structure


resp.rule.rule_id #=> String
resp.rule.name #=> String
resp.rule.metric_name #=> String
resp.rule.predicates #=> Array
resp.rule.predicates[0].negated #=> true/false
resp.rule.predicates[0].type #=> String, one of "IPMatch", "ByteMatch", "SqlInjectionMatch", "GeoMatch", "SizeConstraint", "XssMatch", "RegexMatch"
resp.rule.predicates[0].data_id #=> String

Options Hash (options):

  • :rule_id (required, String)

    The RuleId of the Rule that you want to get. RuleId is returned by CreateRule and by ListRules.

Returns:

See Also:

#get_sampled_requests(options = {}) ⇒ Types::GetSampledRequestsResponse

Gets detailed information about a specified number of requests--a sample--that AWS WAF randomly selects from among the first 5,000 requests that your AWS resource received during a time range that you choose. You can specify a sample size of up to 500 requests, and you can specify any time range in the previous three hours.

GetSampledRequests returns a time range, which is usually the time range that you specified. However, if your resource (such as a CloudFront distribution) received 5,000 requests before the specified time range elapsed, GetSampledRequests returns an updated time range. This new time range indicates the actual period during which AWS WAF selected the requests in the sample.

Examples:

Example: To get a sampled requests


# The following example returns detailed information about 100 requests --a sample-- that AWS WAF randomly selects from among the first 5,000 requests that your AWS resource received between the time period 2016-09-27T15:50Z to 2016-09-27T15:50Z.

resp = client.get_sampled_requests({
  max_items: 100, 
  rule_id: "WAFRule-1-Example", 
  time_window: {
    end_time: Time.parse("2016-09-27T15:50Z"), 
    start_time: Time.parse("2016-09-27T15:50Z"), 
  }, 
  web_acl_id: "createwebacl-1472061481310", 
})

# resp.to_h outputs the following:
{
  population_size: 50, 
  sampled_requests: [
    {
      action: "BLOCK", 
      request: {
        client_ip: "192.0.2.44", 
        country: "US", 
        http_version: "HTTP/1.1", 
        headers: [
          {
            name: "User-Agent", 
            value: "BadBot ", 
          }, 
        ], 
        method: "HEAD", 
      }, 
      timestamp: Time.parse("2016-09-27T14:55Z"), 
      weight: 1, 
    }, 
  ], 
  time_window: {
    end_time: Time.parse("2016-09-27T15:50Z"), 
    start_time: Time.parse("2016-09-27T14:50Z"), 
  }, 
}

Request syntax with placeholder values


resp = client.get_sampled_requests({
  web_acl_id: "ResourceId", # required
  rule_id: "ResourceId", # required
  time_window: { # required
    start_time: Time.now, # required
    end_time: Time.now, # required
  },
  max_items: 1, # required
})

Response structure


resp.sampled_requests #=> Array
resp.sampled_requests[0].request.client_ip #=> String
resp.sampled_requests[0].request.country #=> String
resp.sampled_requests[0].request.uri #=> String
resp.sampled_requests[0].request.method #=> String
resp.sampled_requests[0].request.http_version #=> String
resp.sampled_requests[0].request.headers #=> Array
resp.sampled_requests[0].request.headers[0].name #=> String
resp.sampled_requests[0].request.headers[0].value #=> String
resp.sampled_requests[0].weight #=> Integer
resp.sampled_requests[0].timestamp #=> Time
resp.sampled_requests[0].action #=> String
resp.population_size #=> Integer
resp.time_window.start_time #=> Time
resp.time_window.end_time #=> Time

Options Hash (options):

  • :web_acl_id (required, String)

    The WebACLId of the WebACL for which you want GetSampledRequests to return a sample of requests.

  • :rule_id (required, String)

    RuleId is one of two values:

    • The RuleId of the Rule for which you want GetSampledRequests to return a sample of requests.

    • Default_Action, which causes GetSampledRequests to return a sample of the requests that didn\'t match any of the rules in the specified WebACL.

  • :time_window (required, Types::TimeWindow)

    The start date and time and the end date and time of the range for which you want GetSampledRequests to return a sample of requests. Specify the date and time in the following format: "2016-09-27T14:50Z". You can specify any time range in the previous three hours.

  • :max_items (required, Integer)

    The number of requests that you want AWS WAF to return from among the first 5,000 requests that your AWS resource received during the time range. If your resource received fewer requests than the value of MaxItems, GetSampledRequests returns information about all of them.

Returns:

See Also:

#get_size_constraint_set(options = {}) ⇒ Types::GetSizeConstraintSetResponse

Returns the SizeConstraintSet specified by SizeConstraintSetId.

Examples:

Example: To get a size constraint set


# The following example returns the details of a size constraint match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.get_size_constraint_set({
  size_constraint_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
})

# resp.to_h outputs the following:
{
  size_constraint_set: {
    name: "MySampleSizeConstraintSet", 
    size_constraint_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
    size_constraints: [
      {
        comparison_operator: "GT", 
        field_to_match: {
          type: "QUERY_STRING", 
        }, 
        size: 0, 
        text_transformation: "NONE", 
      }, 
    ], 
  }, 
}

Request syntax with placeholder values


resp = client.get_size_constraint_set({
  size_constraint_set_id: "ResourceId", # required
})

Response structure


resp.size_constraint_set.size_constraint_set_id #=> String
resp.size_constraint_set.name #=> String
resp.size_constraint_set.size_constraints #=> Array
resp.size_constraint_set.size_constraints[0].field_to_match.type #=> String, one of "URI", "QUERY_STRING", "HEADER", "METHOD", "BODY"
resp.size_constraint_set.size_constraints[0].field_to_match.data #=> String
resp.size_constraint_set.size_constraints[0].text_transformation #=> String, one of "NONE", "COMPRESS_WHITE_SPACE", "HTML_ENTITY_DECODE", "LOWERCASE", "CMD_LINE", "URL_DECODE"
resp.size_constraint_set.size_constraints[0].comparison_operator #=> String, one of "EQ", "NE", "LE", "LT", "GE", "GT"
resp.size_constraint_set.size_constraints[0].size #=> Integer

Options Hash (options):

Returns:

See Also:

#get_sql_injection_match_set(options = {}) ⇒ Types::GetSqlInjectionMatchSetResponse

Returns the SqlInjectionMatchSet that is specified by SqlInjectionMatchSetId.

Examples:

Example: To get a SQL injection match set


# The following example returns the details of a SQL injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.get_sql_injection_match_set({
  sql_injection_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
})

# resp.to_h outputs the following:
{
  sql_injection_match_set: {
    name: "MySQLInjectionMatchSet", 
    sql_injection_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
    sql_injection_match_tuples: [
      {
        field_to_match: {
          type: "QUERY_STRING", 
        }, 
        text_transformation: "URL_DECODE", 
      }, 
    ], 
  }, 
}

Request syntax with placeholder values


resp = client.get_sql_injection_match_set({
  sql_injection_match_set_id: "ResourceId", # required
})

Response structure


resp.sql_injection_match_set.sql_injection_match_set_id #=> String
resp.sql_injection_match_set.name #=> String
resp.sql_injection_match_set.sql_injection_match_tuples #=> Array
resp.sql_injection_match_set.sql_injection_match_tuples[0].field_to_match.type #=> String, one of "URI", "QUERY_STRING", "HEADER", "METHOD", "BODY"
resp.sql_injection_match_set.sql_injection_match_tuples[0].field_to_match.data #=> String
resp.sql_injection_match_set.sql_injection_match_tuples[0].text_transformation #=> String, one of "NONE", "COMPRESS_WHITE_SPACE", "HTML_ENTITY_DECODE", "LOWERCASE", "CMD_LINE", "URL_DECODE"

Options Hash (options):

Returns:

See Also:

#get_web_acl(options = {}) ⇒ Types::GetWebACLResponse

Returns the WebACL that is specified by WebACLId.

Examples:

Example: To get a web ACL


# The following example returns the details of a web ACL with the ID createwebacl-1472061481310.

resp = client.get_web_acl({
  web_acl_id: "createwebacl-1472061481310", 
})

# resp.to_h outputs the following:
{
  web_acl: {
    default_action: {
      type: "ALLOW", 
    }, 
    metric_name: "CreateExample", 
    name: "CreateExample", 
    rules: [
      {
        action: {
          type: "ALLOW", 
        }, 
        priority: 1, 
        rule_id: "WAFRule-1-Example", 
      }, 
    ], 
    web_acl_id: "createwebacl-1472061481310", 
  }, 
}

Request syntax with placeholder values


resp = client.get_web_acl({
  web_acl_id: "ResourceId", # required
})

Response structure


resp.web_acl.web_acl_id #=> String
resp.web_acl.name #=> String
resp.web_acl.metric_name #=> String
resp.web_acl.default_action.type #=> String, one of "BLOCK", "ALLOW", "COUNT"
resp.web_acl.rules #=> Array
resp.web_acl.rules[0].priority #=> Integer
resp.web_acl.rules[0].rule_id #=> String
resp.web_acl.rules[0].action.type #=> String, one of "BLOCK", "ALLOW", "COUNT"
resp.web_acl.rules[0].type #=> String, one of "REGULAR", "RATE_BASED"

Options Hash (options):

Returns:

See Also:

#get_xss_match_set(options = {}) ⇒ Types::GetXssMatchSetResponse

Returns the XssMatchSet that is specified by XssMatchSetId.

Examples:

Example: To get an XSS match set


# The following example returns the details of an XSS match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.get_xss_match_set({
  xss_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
})

# resp.to_h outputs the following:
{
  xss_match_set: {
    name: "MySampleXssMatchSet", 
    xss_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
    xss_match_tuples: [
      {
        field_to_match: {
          type: "QUERY_STRING", 
        }, 
        text_transformation: "URL_DECODE", 
      }, 
    ], 
  }, 
}

Request syntax with placeholder values


resp = client.get_xss_match_set({
  xss_match_set_id: "ResourceId", # required
})

Response structure


resp.xss_match_set.xss_match_set_id #=> String
resp.xss_match_set.name #=> String
resp.xss_match_set.xss_match_tuples #=> Array
resp.xss_match_set.xss_match_tuples[0].field_to_match.type #=> String, one of "URI", "QUERY_STRING", "HEADER", "METHOD", "BODY"
resp.xss_match_set.xss_match_tuples[0].field_to_match.data #=> String
resp.xss_match_set.xss_match_tuples[0].text_transformation #=> String, one of "NONE", "COMPRESS_WHITE_SPACE", "HTML_ENTITY_DECODE", "LOWERCASE", "CMD_LINE", "URL_DECODE"

Options Hash (options):

Returns:

See Also:

#list_byte_match_sets(options = {}) ⇒ Types::ListByteMatchSetsResponse

Returns an array of ByteMatchSetSummary objects.

Examples:

Request syntax with placeholder values


resp = client.list_byte_match_sets({
  next_marker: "NextMarker",
  limit: 1,
})

Response structure


resp.next_marker #=> String
resp.byte_match_sets #=> Array
resp.byte_match_sets[0].byte_match_set_id #=> String
resp.byte_match_sets[0].name #=> String

Options Hash (options):

  • :next_marker (String)

    If you specify a value for Limit and you have more ByteMatchSets than the value of Limit, AWS WAF returns a NextMarker value in the response that allows you to list another group of ByteMatchSets. For the second and subsequent ListByteMatchSets requests, specify the value of NextMarker from the previous response to get information about another batch of ByteMatchSets.

  • :limit (Integer)

    Specifies the number of ByteMatchSet objects that you want AWS WAF to return for this request. If you have more ByteMatchSets objects than the number you specify for Limit, the response includes a NextMarker value that you can use to get another batch of ByteMatchSet objects.

Returns:

See Also:

#list_geo_match_sets(options = {}) ⇒ Types::ListGeoMatchSetsResponse

Returns an array of GeoMatchSetSummary objects in the response.

Examples:

Request syntax with placeholder values


resp = client.list_geo_match_sets({
  next_marker: "NextMarker",
  limit: 1,
})

Response structure


resp.next_marker #=> String
resp.geo_match_sets #=> Array
resp.geo_match_sets[0].geo_match_set_id #=> String
resp.geo_match_sets[0].name #=> String

Options Hash (options):

  • :next_marker (String)

    If you specify a value for Limit and you have more GeoMatchSets than the value of Limit, AWS WAF returns a NextMarker value in the response that allows you to list another group of GeoMatchSet objects. For the second and subsequent ListGeoMatchSets requests, specify the value of NextMarker from the previous response to get information about another batch of GeoMatchSet objects.

  • :limit (Integer)

    Specifies the number of GeoMatchSet objects that you want AWS WAF to return for this request. If you have more GeoMatchSet objects than the number you specify for Limit, the response includes a NextMarker value that you can use to get another batch of GeoMatchSet objects.

Returns:

See Also:

#list_ip_sets(options = {}) ⇒ Types::ListIPSetsResponse

Returns an array of IPSetSummary objects in the response.

Examples:

Example: To list IP sets


# The following example returns an array of up to 100 IP match sets.

resp = client.list_ip_sets({
  limit: 100, 
})

# resp.to_h outputs the following:
{
  ip_sets: [
    {
      ip_set_id: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
      name: "MyIPSetFriendlyName", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_ip_sets({
  next_marker: "NextMarker",
  limit: 1,
})

Response structure


resp.next_marker #=> String
resp.ip_sets #=> Array
resp.ip_sets[0].ip_set_id #=> String
resp.ip_sets[0].name #=> String

Options Hash (options):

  • :next_marker (String)

    If you specify a value for Limit and you have more IPSets than the value of Limit, AWS WAF returns a NextMarker value in the response that allows you to list another group of IPSets. For the second and subsequent ListIPSets requests, specify the value of NextMarker from the previous response to get information about another batch of IPSets.

  • :limit (Integer)

    Specifies the number of IPSet objects that you want AWS WAF to return for this request. If you have more IPSet objects than the number you specify for Limit, the response includes a NextMarker value that you can use to get another batch of IPSet objects.

Returns:

See Also:

#list_rate_based_rules(options = {}) ⇒ Types::ListRateBasedRulesResponse

Returns an array of RuleSummary objects.

Examples:

Request syntax with placeholder values


resp = client.list_rate_based_rules({
  next_marker: "NextMarker",
  limit: 1,
})

Response structure


resp.next_marker #=> String
resp.rules #=> Array
resp.rules[0].rule_id #=> String
resp.rules[0].name #=> String

Options Hash (options):

  • :next_marker (String)

    If you specify a value for Limit and you have more Rules than the value of Limit, AWS WAF returns a NextMarker value in the response that allows you to list another group of Rules. For the second and subsequent ListRateBasedRules requests, specify the value of NextMarker from the previous response to get information about another batch of Rules.

  • :limit (Integer)

    Specifies the number of Rules that you want AWS WAF to return for this request. If you have more Rules than the number that you specify for Limit, the response includes a NextMarker value that you can use to get another batch of Rules.

Returns:

See Also:

#list_regex_match_sets(options = {}) ⇒ Types::ListRegexMatchSetsResponse

Returns an array of RegexMatchSetSummary objects.

Examples:

Request syntax with placeholder values


resp = client.list_regex_match_sets({
  next_marker: "NextMarker",
  limit: 1,
})

Response structure


resp.next_marker #=> String
resp.regex_match_sets #=> Array
resp.regex_match_sets[0].regex_match_set_id #=> String
resp.regex_match_sets[0].name #=> String

Options Hash (options):

  • :next_marker (String)

    If you specify a value for Limit and you have more RegexMatchSet objects than the value of Limit, AWS WAF returns a NextMarker value in the response that allows you to list another group of ByteMatchSets. For the second and subsequent ListRegexMatchSets requests, specify the value of NextMarker from the previous response to get information about another batch of RegexMatchSet objects.

  • :limit (Integer)

    Specifies the number of RegexMatchSet objects that you want AWS WAF to return for this request. If you have more RegexMatchSet objects than the number you specify for Limit, the response includes a NextMarker value that you can use to get another batch of RegexMatchSet objects.

Returns:

See Also:

#list_regex_pattern_sets(options = {}) ⇒ Types::ListRegexPatternSetsResponse

Returns an array of RegexPatternSetSummary objects.

Examples:

Request syntax with placeholder values


resp = client.list_regex_pattern_sets({
  next_marker: "NextMarker",
  limit: 1,
})

Response structure


resp.next_marker #=> String
resp.regex_pattern_sets #=> Array
resp.regex_pattern_sets[0].regex_pattern_set_id #=> String
resp.regex_pattern_sets[0].name #=> String

Options Hash (options):

  • :next_marker (String)

    If you specify a value for Limit and you have more RegexPatternSet objects than the value of Limit, AWS WAF returns a NextMarker value in the response that allows you to list another group of RegexPatternSet objects. For the second and subsequent ListRegexPatternSets requests, specify the value of NextMarker from the previous response to get information about another batch of RegexPatternSet objects.

  • :limit (Integer)

    Specifies the number of RegexPatternSet objects that you want AWS WAF to return for this request. If you have more RegexPatternSet objects than the number you specify for Limit, the response includes a NextMarker value that you can use to get another batch of RegexPatternSet objects.

Returns:

See Also:

#list_rules(options = {}) ⇒ Types::ListRulesResponse

Returns an array of RuleSummary objects.

Examples:

Example: To list rules


# The following example returns an array of up to 100 rules.

resp = client.list_rules({
  limit: 100, 
})

# resp.to_h outputs the following:
{
  rules: [
    {
      name: "WAFByteHeaderRule", 
      rule_id: "WAFRule-1-Example", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_rules({
  next_marker: "NextMarker",
  limit: 1,
})

Response structure


resp.next_marker #=> String
resp.rules #=> Array
resp.rules[0].rule_id #=> String
resp.rules[0].name #=> String

Options Hash (options):

  • :next_marker (String)

    If you specify a value for Limit and you have more Rules than the value of Limit, AWS WAF returns a NextMarker value in the response that allows you to list another group of Rules. For the second and subsequent ListRules requests, specify the value of NextMarker from the previous response to get information about another batch of Rules.

  • :limit (Integer)

    Specifies the number of Rules that you want AWS WAF to return for this request. If you have more Rules than the number that you specify for Limit, the response includes a NextMarker value that you can use to get another batch of Rules.

Returns:

See Also:

#list_size_constraint_sets(options = {}) ⇒ Types::ListSizeConstraintSetsResponse

Returns an array of SizeConstraintSetSummary objects.

Examples:

Example: To list a size constraint sets


# The following example returns an array of up to 100 size contraint match sets.

resp = client.list_size_constraint_sets({
  limit: 100, 
})

# resp.to_h outputs the following:
{
  size_constraint_sets: [
    {
      name: "MySampleSizeConstraintSet", 
      size_constraint_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_size_constraint_sets({
  next_marker: "NextMarker",
  limit: 1,
})

Response structure


resp.next_marker #=> String
resp.size_constraint_sets #=> Array
resp.size_constraint_sets[0].size_constraint_set_id #=> String
resp.size_constraint_sets[0].name #=> String

Options Hash (options):

  • :next_marker (String)

    If you specify a value for Limit and you have more SizeConstraintSets than the value of Limit, AWS WAF returns a NextMarker value in the response that allows you to list another group of SizeConstraintSets. For the second and subsequent ListSizeConstraintSets requests, specify the value of NextMarker from the previous response to get information about another batch of SizeConstraintSets.

  • :limit (Integer)

    Specifies the number of SizeConstraintSet objects that you want AWS WAF to return for this request. If you have more SizeConstraintSets objects than the number you specify for Limit, the response includes a NextMarker value that you can use to get another batch of SizeConstraintSet objects.

Returns:

See Also:

#list_sql_injection_match_sets(options = {}) ⇒ Types::ListSqlInjectionMatchSetsResponse

Returns an array of SqlInjectionMatchSet objects.

Examples:

Example: To list SQL injection match sets


# The following example returns an array of up to 100 SQL injection match sets.

resp = client.list_sql_injection_match_sets({
  limit: 100, 
})

# resp.to_h outputs the following:
{
  sql_injection_match_sets: [
    {
      name: "MySQLInjectionMatchSet", 
      sql_injection_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_sql_injection_match_sets({
  next_marker: "NextMarker",
  limit: 1,
})

Response structure


resp.next_marker #=> String
resp.sql_injection_match_sets #=> Array
resp.sql_injection_match_sets[0].sql_injection_match_set_id #=> String
resp.sql_injection_match_sets[0].name #=> String

Options Hash (options):

  • :next_marker (String)

    If you specify a value for Limit and you have more SqlInjectionMatchSet objects than the value of Limit, AWS WAF returns a NextMarker value in the response that allows you to list another group of SqlInjectionMatchSets. For the second and subsequent ListSqlInjectionMatchSets requests, specify the value of NextMarker from the previous response to get information about another batch of SqlInjectionMatchSets.

  • :limit (Integer)

    Specifies the number of SqlInjectionMatchSet objects that you want AWS WAF to return for this request. If you have more SqlInjectionMatchSet objects than the number you specify for Limit, the response includes a NextMarker value that you can use to get another batch of Rules.

Returns:

See Also:

#list_web_acls(options = {}) ⇒ Types::ListWebACLsResponse

Returns an array of WebACLSummary objects in the response.

Examples:

Example: To list Web ACLs


# The following example returns an array of up to 100 web ACLs.

resp = client.list_web_acls({
  limit: 100, 
})

# resp.to_h outputs the following:
{
  web_acls: [
    {
      name: "WebACLexample", 
      web_acl_id: "webacl-1472061481310", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_web_acls({
  next_marker: "NextMarker",
  limit: 1,
})

Response structure


resp.next_marker #=> String
resp.web_acls #=> Array
resp.web_acls[0].web_acl_id #=> String
resp.web_acls[0].name #=> String

Options Hash (options):

  • :next_marker (String)

    If you specify a value for Limit and you have more WebACL objects than the number that you specify for Limit, AWS WAF returns a NextMarker value in the response that allows you to list another group of WebACL objects. For the second and subsequent ListWebACLs requests, specify the value of NextMarker from the previous response to get information about another batch of WebACL objects.

  • :limit (Integer)

    Specifies the number of WebACL objects that you want AWS WAF to return for this request. If you have more WebACL objects than the number that you specify for Limit, the response includes a NextMarker value that you can use to get another batch of WebACL objects.

Returns:

See Also:

#list_xss_match_sets(options = {}) ⇒ Types::ListXssMatchSetsResponse

Returns an array of XssMatchSet objects.

Examples:

Example: To list XSS match sets


# The following example returns an array of up to 100 XSS match sets.

resp = client.list_xss_match_sets({
  limit: 100, 
})

# resp.to_h outputs the following:
{
  xss_match_sets: [
    {
      name: "MySampleXssMatchSet", 
      xss_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
    }, 
  ], 
}

Request syntax with placeholder values


resp = client.list_xss_match_sets({
  next_marker: "NextMarker",
  limit: 1,
})

Response structure


resp.next_marker #=> String
resp.xss_match_sets #=> Array
resp.xss_match_sets[0].xss_match_set_id #=> String
resp.xss_match_sets[0].name #=> String

Options Hash (options):

  • :next_marker (String)

    If you specify a value for Limit and you have more XssMatchSet objects than the value of Limit, AWS WAF returns a NextMarker value in the response that allows you to list another group of XssMatchSets. For the second and subsequent ListXssMatchSets requests, specify the value of NextMarker from the previous response to get information about another batch of XssMatchSets.

  • :limit (Integer)

    Specifies the number of XssMatchSet objects that you want AWS WAF to return for this request. If you have more XssMatchSet objects than the number you specify for Limit, the response includes a NextMarker value that you can use to get another batch of Rules.

Returns:

See Also:

#update_byte_match_set(options = {}) ⇒ Types::UpdateByteMatchSetResponse

Inserts or deletes ByteMatchTuple objects (filters) in a ByteMatchSet. For each ByteMatchTuple object, you specify the following values:

  • Whether to insert or delete the object from the array. If you want to change a ByteMatchSetUpdate object, you delete the existing object and add a new one.

  • The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.

  • The bytes (typically a string that corresponds with ASCII characters) that you want AWS WAF to look for. For more information, including how you specify the values for the AWS WAF API and the AWS CLI or SDKs, see TargetString in the ByteMatchTuple data type.

  • Where to look, such as at the beginning or the end of a query string.

  • Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.

For example, you can add a ByteMatchSetUpdate object that matches web requests in which User-Agent headers contain the string BadBot. You can then configure AWS WAF to block those requests.

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

  1. Create a ByteMatchSet. For more information, see CreateByteMatchSet.

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

  3. 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.

Examples:

Example: To update a byte match set


# The following example deletes a ByteMatchTuple object (filters) in an byte match set with the ID exampleIDs3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.update_byte_match_set({
  byte_match_set_id: "exampleIDs3t-46da-4fdb-b8d5-abc321j569j5", 
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  updates: [
    {
      action: "DELETE", 
      byte_match_tuple: {
        field_to_match: {
          data: "referer", 
          type: "HEADER", 
        }, 
        positional_constraint: "CONTAINS", 
        target_string: "badrefer1", 
        text_transformation: "NONE", 
      }, 
    }, 
  ], 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.update_byte_match_set({
  byte_match_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
  updates: [ # required
    {
      action: "INSERT", # required, accepts INSERT, DELETE
      byte_match_tuple: { # required
        field_to_match: { # required
          type: "URI", # required, accepts URI, QUERY_STRING, HEADER, METHOD, BODY
          data: "MatchFieldData",
        },
        target_string: "data", # required
        text_transformation: "NONE", # required, accepts NONE, COMPRESS_WHITE_SPACE, HTML_ENTITY_DECODE, LOWERCASE, CMD_LINE, URL_DECODE
        positional_constraint: "EXACTLY", # required, accepts EXACTLY, STARTS_WITH, ENDS_WITH, CONTAINS, CONTAINS_WORD
      },
    },
  ],
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#update_geo_match_set(options = {}) ⇒ Types::UpdateGeoMatchSetResponse

Inserts or deletes GeoMatchConstraint objects in an GeoMatchSet. For each GeoMatchConstraint object, you specify the following values:

  • Whether to insert or delete the object from the array. If you want to change an GeoMatchConstraint object, you delete the existing object and add a new one.

  • The Type. The only valid value for Type is Country.

  • The Value, which is a two character code for the country to add to the GeoMatchConstraint object. Valid codes are listed in GeoMatchConstraint$Value.

To create and configure an GeoMatchSet, perform the following steps:

  1. Submit a CreateGeoMatchSet request.

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

  3. Submit an UpdateGeoMatchSet request to specify the country that you want AWS WAF to watch for.

When you update an GeoMatchSet, you specify the country that you want to add and/or the country that you want to delete. If you want to change a country, you delete the existing country and add the new one.

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

Examples:

Request syntax with placeholder values


resp = client.update_geo_match_set({
  geo_match_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
  updates: [ # required
    {
      action: "INSERT", # required, accepts INSERT, DELETE
      geo_match_constraint: { # required
        type: "Country", # required, accepts Country
        value: "AF", # required, accepts AF, AX, AL, DZ, AS, AD, AO, AI, AQ, AG, AR, AM, AW, AU, AT, AZ, BS, BH, BD, BB, BY, BE, BZ, BJ, BM, BT, BO, BQ, BA, BW, BV, BR, IO, BN, BG, BF, BI, KH, CM, CA, CV, KY, CF, TD, CL, CN, CX, CC, CO, KM, CG, CD, CK, CR, CI, HR, CU, CW, CY, CZ, DK, DJ, DM, DO, EC, EG, SV, GQ, ER, EE, ET, FK, FO, FJ, FI, FR, GF, PF, TF, GA, GM, GE, DE, GH, GI, GR, GL, GD, GP, GU, GT, GG, GN, GW, GY, HT, HM, VA, HN, HK, HU, IS, IN, ID, IR, IQ, IE, IM, IL, IT, JM, JP, JE, JO, KZ, KE, KI, KP, KR, KW, KG, LA, LV, LB, LS, LR, LY, LI, LT, LU, MO, MK, MG, MW, MY, MV, ML, MT, MH, MQ, MR, MU, YT, MX, FM, MD, MC, MN, ME, MS, MA, MZ, MM, NA, NR, NP, NL, NC, NZ, NI, NE, NG, NU, NF, MP, NO, OM, PK, PW, PS, PA, PG, PY, PE, PH, PN, PL, PT, PR, QA, RE, RO, RU, RW, BL, SH, KN, LC, MF, PM, VC, WS, SM, ST, SA, SN, RS, SC, SL, SG, SX, SK, SI, SB, SO, ZA, GS, SS, ES, LK, SD, SR, SJ, SZ, SE, CH, SY, TW, TJ, TZ, TH, TL, TG, TK, TO, TT, TN, TR, TM, TC, TV, UG, UA, AE, GB, US, UM, UY, UZ, VU, VE, VN, VG, VI, WF, EH, YE, ZM, ZW
      },
    },
  ],
})

Response structure


resp.change_token #=> String

Options Hash (options):

  • :geo_match_set_id (required, String)

    The GeoMatchSetId of the GeoMatchSet that you want to update. GeoMatchSetId is returned by CreateGeoMatchSet and by ListGeoMatchSets.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

  • :updates (required, Array<Types::GeoMatchSetUpdate>)

    An array of GeoMatchSetUpdate objects that you want to insert into or delete from an GeoMatchSet. For more information, see the applicable data types:

    • GeoMatchSetUpdate: Contains Action and GeoMatchConstraint

    • GeoMatchConstraint: Contains Type and Value

      You can have only one Type and Value per GeoMatchConstraint. To add multiple countries, include multiple GeoMatchSetUpdate objects in your request.

Returns:

See Also:

#update_ip_set(options = {}) ⇒ Types::UpdateIPSetResponse

Inserts or deletes IPSetDescriptor objects in an IPSet. For each IPSetDescriptor object, you specify the following values:

  • Whether to insert or delete the object from the array. If you want to change an IPSetDescriptor object, you delete the existing object and add a new one.

  • The IP address version, IPv4 or IPv6.

  • The IP address in CIDR notation, for example, 192.0.2.0/24 (for the range of IP addresses from 192.0.2.0 to 192.0.2.255) or 192.0.2.44/32 (for the individual IP address 192.0.2.44).

AWS WAF supports /8, /16, /24, and /32 IP address ranges for IPv4, and /24, /32, /48, /56, /64 and /128 for IPv6. For more information about CIDR notation, see the Wikipedia entry Classless Inter-Domain Routing.

IPv6 addresses can be represented using any of the following formats:

  • 1111:0000:0000:0000:0000:0000:0000:0111/128

  • 1111:0:0:0:0:0:0:0111/128

  • 1111::0111/128

  • 1111::111/128

You use an IPSet to specify which web requests you want to allow or block based on the IP addresses that the requests originated from. For example, if you're receiving a lot of requests from one or a small number of IP addresses and you want to block the requests, you can create an IPSet that specifies those IP addresses, and then configure AWS WAF to block the requests.

To create and configure an IPSet, perform the following steps:

  1. Submit a CreateIPSet request.

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

  3. Submit an UpdateIPSet request to specify the IP addresses that you want AWS WAF to watch for.

When you update an IPSet, you specify the IP addresses that you want to add and/or the IP addresses that you want to delete. If you want to change an IP address, you delete the existing IP address and add the new one.

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

Examples:

Example: To update an IP set


# The following example deletes an IPSetDescriptor object in an IP match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.update_ip_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  ip_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
  updates: [
    {
      action: "DELETE", 
      ip_set_descriptor: {
        type: "IPV4", 
        value: "192.0.2.44/32", 
      }, 
    }, 
  ], 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.update_ip_set({
  ip_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
  updates: [ # required
    {
      action: "INSERT", # required, accepts INSERT, DELETE
      ip_set_descriptor: { # required
        type: "IPV4", # required, accepts IPV4, IPV6
        value: "IPSetDescriptorValue", # required
      },
    },
  ],
})

Response structure


resp.change_token #=> String

Options Hash (options):

  • :ip_set_id (required, String)

    The IPSetId of the IPSet that you want to update. IPSetId is returned by CreateIPSet and by ListIPSets.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

  • :updates (required, Array<Types::IPSetUpdate>)

    An array of IPSetUpdate objects that you want to insert into or delete from an IPSet. For more information, see the applicable data types:

Returns:

See Also:

#update_rate_based_rule(options = {}) ⇒ Types::UpdateRateBasedRuleResponse

Inserts or deletes Predicate objects in a rule and updates the RateLimit in the rule.

Each Predicate object identifies a predicate, such as a ByteMatchSet or an IPSet, that specifies the web requests that you want to block or count. The RateLimit specifies the number of requests every five minutes that triggers the rule.

If you add more than one predicate to a RateBasedRule, a request must match all the predicates and exceed the RateLimit to be counted or blocked. For example, suppose you add the following to a RateBasedRule:

  • An IPSet that matches the IP address 192.0.2.44/32

  • A ByteMatchSet that matches BadBot in the User-Agent header

Further, you specify a RateLimit of 15,000.

You then add the RateBasedRule to a WebACL and specify that you want to block 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. Further, requests that match these two conditions much be received at a rate of more than 15,000 every five minutes. If the rate drops below this limit, AWS WAF no longer blocks the requests.

As a second example, suppose you want to limit requests to a particular page on your site. To do this, you could add the following to a RateBasedRule:

  • A ByteMatchSet with FieldToMatch of URI

  • A PositionalConstraint of STARTS_WITH

  • A TargetString of login

Further, you specify a RateLimit of 15,000.

By adding this RateBasedRule to a WebACL, you could limit requests to your login page without affecting the rest of your site.

Examples:

Request syntax with placeholder values


resp = client.update_rate_based_rule({
  rule_id: "ResourceId", # required
  change_token: "ChangeToken", # required
  updates: [ # required
    {
      action: "INSERT", # required, accepts INSERT, DELETE
      predicate: { # required
        negated: false, # required
        type: "IPMatch", # required, accepts IPMatch, ByteMatch, SqlInjectionMatch, GeoMatch, SizeConstraint, XssMatch, RegexMatch
        data_id: "ResourceId", # required
      },
    },
  ],
  rate_limit: 1, # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

  • :rule_id (required, String)

    The RuleId of the RateBasedRule that you want to update. RuleId is returned by CreateRateBasedRule and by ListRateBasedRules.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

  • :updates (required, Array<Types::RuleUpdate>)

    An array of RuleUpdate objects that you want to insert into or delete from a RateBasedRule.

  • :rate_limit (required, Integer)

    The maximum number of requests, which have an identical value in the field specified by the RateKey, allowed in a five-minute period. If the number of requests exceeds the RateLimit and the other predicates specified in the rule are also met, AWS WAF triggers the action that is specified for this rule.

Returns:

See Also:

#update_regex_match_set(options = {}) ⇒ Types::UpdateRegexMatchSetResponse

Inserts or deletes RegexMatchSetUpdate objects (filters) in a RegexMatchSet. For each RegexMatchSetUpdate object, you specify the following values:

  • Whether to insert or delete the object from the array. If you want to change a RegexMatchSetUpdate object, you delete the existing object and add a new one.

  • The part of a web request that you want AWS WAF to inspect, such as a query string or the value of the User-Agent header.

  • The identifier of the pattern (a regular expression) that you want AWS WAF to look for. For more information, see RegexPatternSet.

  • Whether to perform any conversions on the request, such as converting it to lowercase, before inspecting it for the specified string.

For example, you can create a RegexPatternSet that matches any requests with User-Agent headers that contain the string B[a@]dB[o0]t. You can then configure AWS WAF to reject those requests.

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

  1. Create a RegexMatchSet. For more information, see CreateRegexMatchSet.

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

  3. Submit an UpdateRegexMatchSet request to specify the part of the request that you want AWS WAF to inspect (for example, the header or the URI) and the identifier of the RegexPatternSet that contain the regular expression patters 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.

Examples:

Request syntax with placeholder values


resp = client.update_regex_match_set({
  regex_match_set_id: "ResourceId", # required
  updates: [ # required
    {
      action: "INSERT", # required, accepts INSERT, DELETE
      regex_match_tuple: { # required
        field_to_match: { # required
          type: "URI", # required, accepts URI, QUERY_STRING, HEADER, METHOD, BODY
          data: "MatchFieldData",
        },
        text_transformation: "NONE", # required, accepts NONE, COMPRESS_WHITE_SPACE, HTML_ENTITY_DECODE, LOWERCASE, CMD_LINE, URL_DECODE
        regex_pattern_set_id: "ResourceId", # required
      },
    },
  ],
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#update_regex_pattern_set(options = {}) ⇒ Types::UpdateRegexPatternSetResponse

Inserts or deletes RegexMatchSetUpdate objects (filters) in a RegexPatternSet. For each RegexPatternSet object, you specify the following values:

  • Whether to insert or delete the object from the array. If you want to change a RegexPatternSet object, you delete the existing object and add a new one.

  • The regular expression pattern that you want AWS WAF to look for. For more information, see RegexPatternSet.

For example, you can create a RegexPatternString such as B[a@]dB[o0]t. AWS WAF will match this RegexPatternString to:

  • BadBot

  • BadB0t

  • B@dBot

  • B@dB0t

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

  1. Create a RegexPatternSet. For more information, see CreateRegexPatternSet.

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

  3. Submit an UpdateRegexPatternSet request to specify the regular expression pattern 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.

Examples:

Request syntax with placeholder values


resp = client.update_regex_pattern_set({
  regex_pattern_set_id: "ResourceId", # required
  updates: [ # required
    {
      action: "INSERT", # required, accepts INSERT, DELETE
      regex_pattern_string: "RegexPatternString", # required
    },
  ],
  change_token: "ChangeToken", # required
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#update_rule(options = {}) ⇒ Types::UpdateRuleResponse

Inserts or deletes Predicate objects in a Rule. Each Predicate object identifies a predicate, such as a ByteMatchSet or an IPSet, that specifies the web requests that you want to allow, block, or count. If you add more than one predicate to a Rule, a request must match all of the specifications to be allowed, blocked, or counted. For example, suppose you add the following to a Rule:

  • A ByteMatchSet that matches the value BadBot in the User-Agent header

  • An IPSet that matches the IP address 192.0.2.44

You then add the Rule to a WebACL and specify that you want to block requests that satisfy the Rule. For a request to be blocked, the User-Agent header in the request must contain the value BadBot and the request must originate from the IP address 192.0.2.44.

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

  1. Create and update the predicates that you want to include in the Rule.

  2. Create the Rule. See CreateRule.

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

  4. Submit an UpdateRule request to add predicates to the Rule.

  5. Create and update a WebACL that contains the Rule. See CreateWebACL.

If you want to replace one ByteMatchSet or IPSet with another, you delete the existing one and add the new one.

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

Examples:

Example: To update a rule


# The following example deletes a Predicate object in a rule with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.update_rule({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  rule_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
  updates: [
    {
      action: "DELETE", 
      predicate: {
        data_id: "MyByteMatchSetID", 
        negated: false, 
        type: "ByteMatch", 
      }, 
    }, 
  ], 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.update_rule({
  rule_id: "ResourceId", # required
  change_token: "ChangeToken", # required
  updates: [ # required
    {
      action: "INSERT", # required, accepts INSERT, DELETE
      predicate: { # required
        negated: false, # required
        type: "IPMatch", # required, accepts IPMatch, ByteMatch, SqlInjectionMatch, GeoMatch, SizeConstraint, XssMatch, RegexMatch
        data_id: "ResourceId", # required
      },
    },
  ],
})

Response structure


resp.change_token #=> String

Options Hash (options):

  • :rule_id (required, String)

    The RuleId of the Rule that you want to update. RuleId is returned by CreateRule and by ListRules.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

  • :updates (required, Array<Types::RuleUpdate>)

    An array of RuleUpdate objects that you want to insert into or delete from a Rule. For more information, see the applicable data types:

Returns:

See Also:

#update_size_constraint_set(options = {}) ⇒ Types::UpdateSizeConstraintSetResponse

Inserts or deletes SizeConstraint objects (filters) in a SizeConstraintSet. For each SizeConstraint object, you specify the following values:

  • Whether to insert or delete the object from the array. If you want to change a SizeConstraintSetUpdate object, you delete the existing object and add a new one.

  • The part of a web request that you want AWS WAF to evaluate, such as the length of a query string or the length of the User-Agent header.

  • Whether to perform any transformations on the request, such as converting it to lowercase, before checking its length. Note that transformations of the request body are not supported because the AWS resource forwards only the first 8192 bytes of your request to AWS WAF.

  • A ComparisonOperator used for evaluating the selected part of the request against the specified Size, such as equals, greater than, less than, and so on.

  • The length, in bytes, that you want AWS WAF to watch for in selected part of the request. The length is computed after applying the transformation.

For example, you can add a SizeConstraintSetUpdate object that matches web requests in which the length of the User-Agent header is greater than 100 bytes. You can then configure AWS WAF to block those requests.

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

  1. Create a SizeConstraintSet. For more information, see CreateSizeConstraintSet.

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

  3. Submit an UpdateSizeConstraintSet 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.

Examples:

Example: To update a size constraint set


# The following example deletes a SizeConstraint object (filters) in a size constraint set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.update_size_constraint_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  size_constraint_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
  updates: [
    {
      action: "DELETE", 
      size_constraint: {
        comparison_operator: "GT", 
        field_to_match: {
          type: "QUERY_STRING", 
        }, 
        size: 0, 
        text_transformation: "NONE", 
      }, 
    }, 
  ], 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.update_size_constraint_set({
  size_constraint_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
  updates: [ # required
    {
      action: "INSERT", # required, accepts INSERT, DELETE
      size_constraint: { # required
        field_to_match: { # required
          type: "URI", # required, accepts URI, QUERY_STRING, HEADER, METHOD, BODY
          data: "MatchFieldData",
        },
        text_transformation: "NONE", # required, accepts NONE, COMPRESS_WHITE_SPACE, HTML_ENTITY_DECODE, LOWERCASE, CMD_LINE, URL_DECODE
        comparison_operator: "EQ", # required, accepts EQ, NE, LE, LT, GE, GT
        size: 1, # required
      },
    },
  ],
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#update_sql_injection_match_set(options = {}) ⇒ Types::UpdateSqlInjectionMatchSetResponse

Inserts or deletes SqlInjectionMatchTuple objects (filters) in a SqlInjectionMatchSet. For each SqlInjectionMatchTuple object, you specify the following values:

  • Action: Whether to insert the object into or delete the object from the array. To change a SqlInjectionMatchTuple, you delete the existing object and add a new one.

  • FieldToMatch: The part of web requests that you want AWS WAF to inspect and, if you want AWS WAF to inspect a header, the name of the header.

  • TextTransformation: Which text transformation, if any, to perform on the web request before inspecting the request for snippets of malicious SQL code.

You use SqlInjectionMatchSet objects to specify which CloudFront requests you want to allow, block, or count. For example, if you're receiving requests that contain snippets of SQL code in the query string and you want to block the requests, you can create a SqlInjectionMatchSet with the applicable settings, and then configure AWS WAF to block the requests.

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

  1. Submit a CreateSqlInjectionMatchSet request.

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

  3. Submit an UpdateSqlInjectionMatchSet request to specify the parts of web requests that you want AWS WAF to inspect for snippets of SQL code.

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

Examples:

Example: To update a SQL injection match set


# The following example deletes a SqlInjectionMatchTuple object (filters) in a SQL injection match set with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.update_sql_injection_match_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  sql_injection_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
  updates: [
    {
      action: "DELETE", 
      sql_injection_match_tuple: {
        field_to_match: {
          type: "QUERY_STRING", 
        }, 
        text_transformation: "URL_DECODE", 
      }, 
    }, 
  ], 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.update_sql_injection_match_set({
  sql_injection_match_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
  updates: [ # required
    {
      action: "INSERT", # required, accepts INSERT, DELETE
      sql_injection_match_tuple: { # required
        field_to_match: { # required
          type: "URI", # required, accepts URI, QUERY_STRING, HEADER, METHOD, BODY
          data: "MatchFieldData",
        },
        text_transformation: "NONE", # required, accepts NONE, COMPRESS_WHITE_SPACE, HTML_ENTITY_DECODE, LOWERCASE, CMD_LINE, URL_DECODE
      },
    },
  ],
})

Response structure


resp.change_token #=> String

Options Hash (options):

Returns:

See Also:

#update_web_acl(options = {}) ⇒ Types::UpdateWebACLResponse

Inserts or deletes ActivatedRule objects in a WebACL. Each Rule identifies web requests that you want to allow, block, or count. When you update a WebACL, you specify the following values:

  • A default action for the WebACL, either ALLOW or BLOCK. AWS WAF performs the default action if a request doesn't match the criteria in any of the Rules in a WebACL.

  • The Rules that you want to add and/or delete. If you want to replace one Rule with another, you delete the existing Rule and add the new one.

  • For each Rule, whether you want AWS WAF to allow requests, block requests, or count requests that match the conditions in the Rule.

  • The order in which you want AWS WAF to evaluate the Rules in a WebACL. If you add more than one Rule to a WebACL, AWS WAF evaluates each request against the Rules in order based on the value of Priority. (The Rule that has the lowest value for Priority is evaluated first.) When a web request matches all of the predicates (such as ByteMatchSets and IPSets) in a Rule, AWS WAF immediately takes the corresponding action, allow or block, and doesn't evaluate the request against the remaining Rules in the WebACL, if any.

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

  1. Create and update the predicates that you want to include in Rules. For more information, see CreateByteMatchSet, UpdateByteMatchSet, CreateIPSet, UpdateIPSet, CreateSqlInjectionMatchSet, and UpdateSqlInjectionMatchSet.

  2. Create and update the Rules that you want to include in the WebACL. For more information, see CreateRule and UpdateRule.

  3. Create a WebACL. See CreateWebACL.

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

  5. Submit an UpdateWebACL request to specify the Rules that you want to include in the WebACL, to specify the default action, and to associate the WebACL with a CloudFront distribution.

Be aware that if you try to add a RATE_BASED rule to a web ACL without setting the rule type when first creating the rule, the UpdateWebACL request will fail because the request tries to add a REGULAR rule (the default rule type) with the specified ID, which does not exist.

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

Examples:

Example: To update a Web ACL


# The following example deletes an ActivatedRule object in a WebACL with the ID webacl-1472061481310.

resp = client.update_web_acl({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  default_action: {
    type: "ALLOW", 
  }, 
  updates: [
    {
      action: "DELETE", 
      activated_rule: {
        action: {
          type: "ALLOW", 
        }, 
        priority: 1, 
        rule_id: "WAFRule-1-Example", 
      }, 
    }, 
  ], 
  web_acl_id: "webacl-1472061481310", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.update_web_acl({
  web_acl_id: "ResourceId", # required
  change_token: "ChangeToken", # required
  updates: [
    {
      action: "INSERT", # required, accepts INSERT, DELETE
      activated_rule: { # required
        priority: 1, # required
        rule_id: "ResourceId", # required
        action: { # required
          type: "BLOCK", # required, accepts BLOCK, ALLOW, COUNT
        },
        type: "REGULAR", # accepts REGULAR, RATE_BASED
      },
    },
  ],
  default_action: {
    type: "BLOCK", # required, accepts BLOCK, ALLOW, COUNT
  },
})

Response structure


resp.change_token #=> String

Options Hash (options):

  • :web_acl_id (required, String)

    The WebACLId of the WebACL that you want to update. WebACLId is returned by CreateWebACL and by ListWebACLs.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

  • :updates (Array<Types::WebACLUpdate>)

    An array of updates to make to the WebACL.

    An array of WebACLUpdate objects that you want to insert into or delete from a WebACL. For more information, see the applicable data types:

  • :default_action (Types::WafAction)

    A default action for the web ACL, either ALLOW or BLOCK. AWS WAF performs the default action if a request doesn\'t match the criteria in any of the rules in a web ACL.

Returns:

See Also:

#update_xss_match_set(options = {}) ⇒ Types::UpdateXssMatchSetResponse

Inserts or deletes XssMatchTuple objects (filters) in an XssMatchSet. For each XssMatchTuple object, you specify the following values:

  • Action: Whether to insert the object into or delete the object from the array. To change a XssMatchTuple, you delete the existing object and add a new one.

  • FieldToMatch: The part of web requests that you want AWS WAF to inspect and, if you want AWS WAF to inspect a header, the name of the header.

  • TextTransformation: Which text transformation, if any, to perform on the web request before inspecting the request for cross-site scripting attacks.

You use XssMatchSet objects to specify which CloudFront requests you want to allow, block, or count. For example, if you're receiving requests that contain cross-site scripting attacks in the request body and you want to block the requests, you can create an XssMatchSet with the applicable settings, and then configure AWS WAF to block the requests.

To create and configure an XssMatchSet, perform the following steps:

  1. Submit a CreateXssMatchSet request.

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

  3. Submit an UpdateXssMatchSet request to specify the parts of web requests that you want AWS WAF to inspect for cross-site scripting attacks.

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

Examples:

Example: To update an XSS match set


# The following example deletes an XssMatchTuple object (filters) in an XssMatchSet with the ID example1ds3t-46da-4fdb-b8d5-abc321j569j5.

resp = client.update_xss_match_set({
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
  updates: [
    {
      action: "DELETE", 
      xss_match_tuple: {
        field_to_match: {
          type: "QUERY_STRING", 
        }, 
        text_transformation: "URL_DECODE", 
      }, 
    }, 
  ], 
  xss_match_set_id: "example1ds3t-46da-4fdb-b8d5-abc321j569j5", 
})

# resp.to_h outputs the following:
{
  change_token: "abcd12f2-46da-4fdb-b8d5-fbd4c466928f", 
}

Request syntax with placeholder values


resp = client.update_xss_match_set({
  xss_match_set_id: "ResourceId", # required
  change_token: "ChangeToken", # required
  updates: [ # required
    {
      action: "INSERT", # required, accepts INSERT, DELETE
      xss_match_tuple: { # required
        field_to_match: { # required
          type: "URI", # required, accepts URI, QUERY_STRING, HEADER, METHOD, BODY
          data: "MatchFieldData",
        },
        text_transformation: "NONE", # required, accepts NONE, COMPRESS_WHITE_SPACE, HTML_ENTITY_DECODE, LOWERCASE, CMD_LINE, URL_DECODE
      },
    },
  ],
})

Response structure


resp.change_token #=> String

Options Hash (options):

  • :xss_match_set_id (required, String)

    The XssMatchSetId of the XssMatchSet that you want to update. XssMatchSetId is returned by CreateXssMatchSet and by ListXssMatchSets.

  • :change_token (required, String)

    The value returned by the most recent call to GetChangeToken.

  • :updates (required, Array<Types::XssMatchSetUpdate>)

    An array of XssMatchSetUpdate objects that you want to insert into or delete from a XssMatchSet. For more information, see the applicable data types:

Returns:

See Also:

#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean

Waiters polls an API operation until a resource enters a desired state.

Basic Usage

Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.

# polls in a loop, sleeping between attempts client.waiter_until(waiter_name, params)

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You configure waiters by passing a block to #wait_until:

# poll for ~25 seconds
client.wait_until(...) do |w|
  w.max_attempts = 5
  w.delay = 5
end

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
client.wait_until(...) do |w|

  # disable max attempts
  w.max_attempts = nil

  # poll for 1 hour, instead of a number of attempts
  w.before_wait do |attempts, response|
    throw :failure if Time.now - started_at > 3600
  end

end

Handling Errors

When a waiter is successful, it returns true. When a waiter fails, it raises an error. All errors raised extend from Aws::Waiters::Errors::WaiterFailed.

begin
  client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

Parameters:

  • waiter_name (Symbol)

    The name of the waiter. See #waiter_names for a full list of supported waiters.

  • params (Hash) (defaults to: {})

    Additional request parameters. See the #waiter_names for a list of supported waiters and what request they call. The called request determines the list of accepted parameters.

Yield Parameters:

Returns:

  • (Boolean)

    Returns true if the waiter was successful.

Raises:

  • (Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

  • (Errors::TooManyAttemptsError)

    Raised when the configured maximum number of attempts have been made, and the waiter is not yet successful.

  • (Errors::UnexpectedError)

    Raised when an error is encounted while polling for a resource that is not expected.

  • (Errors::NoSuchWaiterError)

    Raised when you request to wait for an unknown state.

#waiter_namesArray<Symbol>

Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:

Waiter NameClient MethodDefault Delay:Default Max Attempts:

Returns:

  • (Array<Symbol>)

    the list of supported waiters.