Class: AWSCDK::CloudFront::ErrorResponse

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
cloud_front/error_response.rb

Overview

Options for configuring custom error responses.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_status:, response_http_status: nil, response_page_path: nil, ttl: nil) ⇒ ErrorResponse

Returns a new instance of ErrorResponse.

Parameters:

  • http_status (Numeric)

    The HTTP status code for which you want to specify a custom error page and/or a caching duration.

  • response_http_status (Numeric, nil) (defaults to: nil)

    The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.

  • response_page_path (String, nil) (defaults to: nil)

    The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the httpStatus, for example, /4xx-errors/403-forbidden.html.

  • ttl (AWSCDK::Duration, nil) (defaults to: nil)

    The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in ErrorCode.



11
12
13
14
15
16
17
18
19
20
# File 'cloud_front/error_response.rb', line 11

def initialize(http_status:, response_http_status: nil, response_page_path: nil, ttl: nil)
  @http_status = http_status
  Jsii::Type.check_type(@http_status, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "httpStatus")
  @response_http_status = response_http_status
  Jsii::Type.check_type(@response_http_status, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "responseHttpStatus") unless @response_http_status.nil?
  @response_page_path = response_page_path
  Jsii::Type.check_type(@response_page_path, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "responsePagePath") unless @response_page_path.nil?
  @ttl = ttl
  Jsii::Type.check_type(@ttl, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "ttl") unless @ttl.nil?
end

Instance Attribute Details

#http_statusNumeric (readonly)

The HTTP status code for which you want to specify a custom error page and/or a caching duration.

Returns:

  • (Numeric)


25
26
27
# File 'cloud_front/error_response.rb', line 25

def http_status
  @http_status
end

#response_http_statusNumeric? (readonly)

Note:

Default: - the error code will be returned as the response code.

The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.

If you specify a value for response_http_status, you must also specify a value for response_page_path.

Returns:

  • (Numeric, nil)


32
33
34
# File 'cloud_front/error_response.rb', line 32

def response_http_status
  @response_http_status
end

#response_page_pathString? (readonly)

Note:

Default: - the default CloudFront response is shown.

The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the httpStatus, for example, /4xx-errors/403-forbidden.html.

Returns:

  • (String, nil)


37
38
39
# File 'cloud_front/error_response.rb', line 37

def response_page_path
  @response_page_path
end

#ttlAWSCDK::Duration? (readonly)

Note:

Default: - the default caching TTL behavior applies

The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in ErrorCode.

Returns:



42
43
44
# File 'cloud_front/error_response.rb', line 42

def ttl
  @ttl
end

Class Method Details

.jsii_propertiesObject



44
45
46
47
48
49
50
51
# File 'cloud_front/error_response.rb', line 44

def self.jsii_properties
  {
    :http_status => "httpStatus",
    :response_http_status => "responseHttpStatus",
    :response_page_path => "responsePagePath",
    :ttl => "ttl",
  }
end

Instance Method Details

#to_jsiiObject



53
54
55
56
57
58
59
60
61
62
# File 'cloud_front/error_response.rb', line 53

def to_jsii
  result = {}
  result.merge!({
    "httpStatus" => @http_status,
    "responseHttpStatus" => @response_http_status,
    "responsePagePath" => @response_page_path,
    "ttl" => @ttl,
  })
  result.compact
end