Class: AWSCDK::Lambda::CfnURL::CorsProperty

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

Overview

The Cross-Origin Resource Sharing (CORS) settings for your function URL. Use CORS to grant access to your function URL from any origin. You can also use CORS to control access for specific HTTP headers and methods in requests to your function URL.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allow_credentials: nil, allow_headers: nil, allow_methods: nil, allow_origins: nil, expose_headers: nil, max_age: nil) ⇒ CorsProperty

Returns a new instance of CorsProperty.

Parameters:

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

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

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

    The HTTP headers that origins can include in requests to your function URL.

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

    The HTTP methods that are allowed when calling your function URL.

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

    The origins that can access your function URL.

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

    The HTTP headers in your function response that you want to expose to origins that call your function URL.

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

    The maximum amount of time, in seconds, that browsers can cache results of a preflight request.



568
569
570
571
572
573
574
575
576
577
578
579
580
581
# File 'lambda/cfn_url.rb', line 568

def initialize(allow_credentials: nil, allow_headers: nil, allow_methods: nil, allow_origins: nil, expose_headers: nil, max_age: nil)
  @allow_credentials = allow_credentials
  Jsii::Type.check_type(@allow_credentials, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3sicHJpbWl0aXZlIjoiYm9vbGVhbiJ9LHsiZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifV19fQ==")), "allowCredentials") unless @allow_credentials.nil?
  @allow_headers = allow_headers
  Jsii::Type.check_type(@allow_headers, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowHeaders") unless @allow_headers.nil?
  @allow_methods = allow_methods
  Jsii::Type.check_type(@allow_methods, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowMethods") unless @allow_methods.nil?
  @allow_origins = allow_origins
  Jsii::Type.check_type(@allow_origins, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowOrigins") unless @allow_origins.nil?
  @expose_headers = expose_headers
  Jsii::Type.check_type(@expose_headers, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "exposeHeaders") unless @expose_headers.nil?
  @max_age = max_age
  Jsii::Type.check_type(@max_age, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "maxAge") unless @max_age.nil?
end

Instance Attribute Details

#allow_credentialsBoolean, ... (readonly)

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

The default is false .



589
590
591
# File 'lambda/cfn_url.rb', line 589

def allow_credentials
  @allow_credentials
end

#allow_headersArray<String>? (readonly)

The HTTP headers that origins can include in requests to your function URL.

For example: Date , Keep-Alive , X-Custom-Header .



596
597
598
# File 'lambda/cfn_url.rb', line 596

def allow_headers
  @allow_headers
end

#allow_methodsArray<String>? (readonly)

The HTTP methods that are allowed when calling your function URL.

For example: GET , POST , DELETE , or the wildcard character ( * ).



603
604
605
# File 'lambda/cfn_url.rb', line 603

def allow_methods
  @allow_methods
end

#allow_originsArray<String>? (readonly)

The origins that can access your function URL.

You can list any number of specific origins, separated by a comma. For example: https://www.example.com , http://localhost:60905 .

Alternatively, you can grant access to all origins with the wildcard character ( * ).



612
613
614
# File 'lambda/cfn_url.rb', line 612

def allow_origins
  @allow_origins
end

#expose_headersArray<String>? (readonly)

The HTTP headers in your function response that you want to expose to origins that call your function URL.

For example: Date , Keep-Alive , X-Custom-Header .



619
620
621
# File 'lambda/cfn_url.rb', line 619

def expose_headers
  @expose_headers
end

#max_ageNumeric? (readonly)

The maximum amount of time, in seconds, that browsers can cache results of a preflight request.

By default, this is set to 0 , which means the browser will not cache results.



626
627
628
# File 'lambda/cfn_url.rb', line 626

def max_age
  @max_age
end

Class Method Details

.jsii_propertiesObject



628
629
630
631
632
633
634
635
636
637
# File 'lambda/cfn_url.rb', line 628

def self.jsii_properties
  {
    :allow_credentials => "allowCredentials",
    :allow_headers => "allowHeaders",
    :allow_methods => "allowMethods",
    :allow_origins => "allowOrigins",
    :expose_headers => "exposeHeaders",
    :max_age => "maxAge",
  }
end

Instance Method Details

#to_jsiiObject



639
640
641
642
643
644
645
646
647
648
649
650
# File 'lambda/cfn_url.rb', line 639

def to_jsii
  result = {}
  result.merge!({
    "allowCredentials" => @allow_credentials,
    "allowHeaders" => @allow_headers,
    "allowMethods" => @allow_methods,
    "allowOrigins" => @allow_origins,
    "exposeHeaders" => @expose_headers,
    "maxAge" => @max_age,
  })
  result.compact
end