Class: AWSCDK::WAFv2::CfnWebACL::CustomResponseProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
wa_fv2/cfn_web_acl.rb

Overview

A custom response to send to the client.

You can define a custom response for rule actions and default web ACL actions that are set to the block action.

For information about customizing web requests and responses, see Customizing web requests and responses in AWS WAF in the AWS WAF developer guide .

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_code:, custom_response_body_key: nil, response_headers: nil) ⇒ CustomResponseProperty

Returns a new instance of CustomResponseProperty.

Parameters:



2140
2141
2142
2143
2144
2145
2146
2147
# File 'wa_fv2/cfn_web_acl.rb', line 2140

def initialize(response_code:, custom_response_body_key: nil, response_headers: nil)
  @response_code = response_code
  Jsii::Type.check_type(@response_code, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "responseCode")
  @custom_response_body_key = custom_response_body_key
  Jsii::Type.check_type(@custom_response_body_key, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "customResponseBodyKey") unless @custom_response_body_key.nil?
  @response_headers = response_headers
  Jsii::Type.check_type(@response_headers, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImNvbGxlY3Rpb24iOnsiZWxlbWVudHR5cGUiOnsidW5pb24iOnsidHlwZXMiOlt7ImZxbiI6ImF3cy1jZGstbGliLklSZXNvbHZhYmxlIn0seyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfd2FmdjIuQ2ZuV2ViQUNMLkN1c3RvbUhUVFBIZWFkZXJQcm9wZXJ0eSJ9XX19LCJraW5kIjoiYXJyYXkifX1dfX0=")), "responseHeaders") unless @response_headers.nil?
end

Instance Attribute Details

#custom_response_body_keyString? (readonly)

References the response body that you want AWS WAF to return to the web request client.

You can define a custom response for a rule action or a default web ACL action that is set to block. To do this, you first define the response body key and value in the CustomResponseBodies setting for the WebACL or RuleGroup where you want to use it. Then, in the rule action or web ACL default action BlockAction setting, you reference the response body using this key.



2162
2163
2164
# File 'wa_fv2/cfn_web_acl.rb', line 2162

def custom_response_body_key
  @custom_response_body_key
end

#response_codeNumeric (readonly)

The HTTP status code to return to the client.

For a list of status codes that you can use in your custom responses, see Supported status codes for custom response in the AWS WAF Developer Guide .



2155
2156
2157
# File 'wa_fv2/cfn_web_acl.rb', line 2155

def response_code
  @response_code
end

#response_headersAWSCDK::IResolvable, ... (readonly)

The HTTP headers to use in the response.

You can specify any header name except for content-type . Duplicate header names are not allowed.

For information about the limits on count and size for custom request and response settings, see AWS WAF quotas in the AWS WAF Developer Guide .



2171
2172
2173
# File 'wa_fv2/cfn_web_acl.rb', line 2171

def response_headers
  @response_headers
end

Class Method Details

.jsii_propertiesObject



2173
2174
2175
2176
2177
2178
2179
# File 'wa_fv2/cfn_web_acl.rb', line 2173

def self.jsii_properties
  {
    :response_code => "responseCode",
    :custom_response_body_key => "customResponseBodyKey",
    :response_headers => "responseHeaders",
  }
end

Instance Method Details

#to_jsiiObject



2181
2182
2183
2184
2185
2186
2187
2188
2189
# File 'wa_fv2/cfn_web_acl.rb', line 2181

def to_jsii
  result = {}
  result.merge!({
    "responseCode" => @response_code,
    "customResponseBodyKey" => @custom_response_body_key,
    "responseHeaders" => @response_headers,
  })
  result.compact
end