Class: AWSCDK::Lambda::FunctionURLCorsOptions

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
lambda/function_url_cors_options.rb

Overview

Specifies a cross-origin access property for a function URL.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allow_credentials: nil, allowed_headers: nil, allowed_methods: nil, allowed_origins: nil, exposed_headers: nil, max_age: nil) ⇒ FunctionURLCorsOptions

Returns a new instance of FunctionURLCorsOptions.

Parameters:

  • allow_credentials (Boolean, nil) (defaults to: nil)

    Whether to allow cookies or other credentials in requests to your function URL.

  • allowed_headers (Array<String>, nil) (defaults to: nil)

    Headers that are specified in the Access-Control-Request-Headers header.

  • allowed_methods (Array<AWSCDK::Lambda::HttpMethod>, nil) (defaults to: nil)

    An HTTP method that you allow the origin to execute.

  • allowed_origins (Array<String>, nil) (defaults to: nil)

    One or more origins you want customers to be able to access the bucket from.

  • exposed_headers (Array<String>, nil) (defaults to: nil)

    One or more headers in the response that you want customers to be able to access from their applications.

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

    The time in seconds that your browser is to cache the preflight response for the specified resource.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lambda/function_url_cors_options.rb', line 13

def initialize(allow_credentials: nil, allowed_headers: nil, allowed_methods: nil, allowed_origins: nil, exposed_headers: nil, max_age: nil)
  @allow_credentials = allow_credentials
  Jsii::Type.check_type(@allow_credentials, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "allowCredentials") unless @allow_credentials.nil?
  @allowed_headers = allowed_headers
  Jsii::Type.check_type(@allowed_headers, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowedHeaders") unless @allowed_headers.nil?
  @allowed_methods = allowed_methods
  Jsii::Type.check_type(@allowed_methods, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19sYW1iZGEuSHR0cE1ldGhvZCJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowedMethods") unless @allowed_methods.nil?
  @allowed_origins = allowed_origins
  Jsii::Type.check_type(@allowed_origins, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowedOrigins") unless @allowed_origins.nil?
  @exposed_headers = exposed_headers
  Jsii::Type.check_type(@exposed_headers, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "exposedHeaders") unless @exposed_headers.nil?
  @max_age = max_age
  Jsii::Type.check_type(@max_age, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "maxAge") unless @max_age.nil?
end

Instance Attribute Details

#allow_credentialsBoolean? (readonly)

Note:

Default: false

Whether to allow cookies or other credentials in requests to your function URL.

Returns:

  • (Boolean, nil)


32
33
34
# File 'lambda/function_url_cors_options.rb', line 32

def allow_credentials
  @allow_credentials
end

#allowed_headersArray<String>? (readonly)

Note:

Default: - No headers allowed.

Headers that are specified in the Access-Control-Request-Headers header.

Returns:

  • (Array<String>, nil)


37
38
39
# File 'lambda/function_url_cors_options.rb', line 37

def allowed_headers
  @allowed_headers
end

#allowed_methodsArray<AWSCDK::Lambda::HttpMethod>? (readonly)

Note:

Default: - [HttpMethod.ALL]

An HTTP method that you allow the origin to execute.

Returns:



42
43
44
# File 'lambda/function_url_cors_options.rb', line 42

def allowed_methods
  @allowed_methods
end

#allowed_originsArray<String>? (readonly)

Note:

Default: - No origins allowed.

One or more origins you want customers to be able to access the bucket from.

Returns:

  • (Array<String>, nil)


47
48
49
# File 'lambda/function_url_cors_options.rb', line 47

def allowed_origins
  @allowed_origins
end

#exposed_headersArray<String>? (readonly)

Note:

Default: - No headers exposed.

One or more headers in the response that you want customers to be able to access from their applications.

Returns:

  • (Array<String>, nil)


52
53
54
# File 'lambda/function_url_cors_options.rb', line 52

def exposed_headers
  @exposed_headers
end

#max_ageAWSCDK::Duration? (readonly)

Note:

Default: - Browser default of 5 seconds.

The time in seconds that your browser is to cache the preflight response for the specified resource.

Returns:



57
58
59
# File 'lambda/function_url_cors_options.rb', line 57

def max_age
  @max_age
end

Class Method Details

.jsii_propertiesObject



59
60
61
62
63
64
65
66
67
68
# File 'lambda/function_url_cors_options.rb', line 59

def self.jsii_properties
  {
    :allow_credentials => "allowCredentials",
    :allowed_headers => "allowedHeaders",
    :allowed_methods => "allowedMethods",
    :allowed_origins => "allowedOrigins",
    :exposed_headers => "exposedHeaders",
    :max_age => "maxAge",
  }
end

Instance Method Details

#to_jsiiObject



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lambda/function_url_cors_options.rb', line 70

def to_jsii
  result = {}
  result.merge!({
    "allowCredentials" => @allow_credentials,
    "allowedHeaders" => @allowed_headers,
    "allowedMethods" => @allowed_methods,
    "allowedOrigins" => @allowed_origins,
    "exposedHeaders" => @exposed_headers,
    "maxAge" => @max_age,
  })
  result.compact
end