Class: AWSCDK::S3::CorsRule

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
s3/cors_rule.rb

Overview

Specifies a cross-origin access rule for an Amazon S3 bucket.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allowed_methods:, allowed_origins:, allowed_headers: nil, exposed_headers: nil, id: nil, max_age: nil) ⇒ CorsRule

Returns a new instance of CorsRule.

Parameters:

  • allowed_methods (Array<AWSCDK::S3::HttpMethods>)

    An HTTP method that you allow the origin to execute.

  • allowed_origins (Array<String>)

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

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

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

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

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

    A unique identifier for this rule.

  • max_age (Numeric, 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 's3/cors_rule.rb', line 13

def initialize(allowed_methods:, allowed_origins:, allowed_headers: nil, exposed_headers: nil, id: nil, max_age: nil)
  @allowed_methods = allowed_methods
  Jsii::Type.check_type(@allowed_methods, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19zMy5IdHRwTWV0aG9kcyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowedMethods")
  @allowed_origins = allowed_origins
  Jsii::Type.check_type(@allowed_origins, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowedOrigins")
  @allowed_headers = allowed_headers
  Jsii::Type.check_type(@allowed_headers, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "allowedHeaders") unless @allowed_headers.nil?
  @exposed_headers = exposed_headers
  Jsii::Type.check_type(@exposed_headers, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "exposedHeaders") unless @exposed_headers.nil?
  @id = id
  Jsii::Type.check_type(@id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id") unless @id.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

#allowed_headersArray<String>? (readonly)

Note:

Default: - No headers allowed.

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

Returns:

  • (Array<String>, nil)


40
41
42
# File 's3/cors_rule.rb', line 40

def allowed_headers
  @allowed_headers
end

#allowed_methodsArray<AWSCDK::S3::HttpMethods> (readonly)

An HTTP method that you allow the origin to execute.

Returns:



31
32
33
# File 's3/cors_rule.rb', line 31

def allowed_methods
  @allowed_methods
end

#allowed_originsArray<String> (readonly)

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

Returns:

  • (Array<String>)


35
36
37
# File 's3/cors_rule.rb', line 35

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)


45
46
47
# File 's3/cors_rule.rb', line 45

def exposed_headers
  @exposed_headers
end

#idString? (readonly)

Note:

Default: - No id specified.

A unique identifier for this rule.

Returns:

  • (String, nil)


50
51
52
# File 's3/cors_rule.rb', line 50

def id
  @id
end

#max_ageNumeric? (readonly)

Note:

Default: - No caching.

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

Returns:

  • (Numeric, nil)


55
56
57
# File 's3/cors_rule.rb', line 55

def max_age
  @max_age
end

Class Method Details

.jsii_propertiesObject



57
58
59
60
61
62
63
64
65
66
# File 's3/cors_rule.rb', line 57

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

Instance Method Details

#to_jsiiObject



68
69
70
71
72
73
74
75
76
77
78
79
# File 's3/cors_rule.rb', line 68

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