Class: AWSCDK::CloudFront::AddBehaviorOptions

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

Overview

Options for adding a new behavior to a Distribution.

Direct Known Subclasses

BehaviorOptions

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allowed_methods: nil, cached_methods: nil, cache_policy: nil, compress: nil, edge_lambdas: nil, enable_grpc: nil, function_associations: nil, origin_request_policy: nil, realtime_log_config: nil, response_headers_policy: nil, smooth_streaming: nil, trusted_key_groups: nil, viewer_protocol_policy: nil) ⇒ AddBehaviorOptions

Returns a new instance of AddBehaviorOptions.

Parameters:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'cloud_front/add_behavior_options.rb', line 20

def initialize(allowed_methods: nil, cached_methods: nil, cache_policy: nil, compress: nil, edge_lambdas: nil, enable_grpc: nil, function_associations: nil, origin_request_policy: nil, realtime_log_config: nil, response_headers_policy: nil, smooth_streaming: nil, trusted_key_groups: nil, viewer_protocol_policy: nil)
  @allowed_methods = allowed_methods
  Jsii::Type.check_type(@allowed_methods, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5BbGxvd2VkTWV0aG9kcyJ9")), "allowedMethods") unless @allowed_methods.nil?
  @cached_methods = cached_methods
  Jsii::Type.check_type(@cached_methods, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5DYWNoZWRNZXRob2RzIn0=")), "cachedMethods") unless @cached_methods.nil?
  @cache_policy = cache_policy
  Jsii::Type.check_type(@cache_policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5pbnRlcmZhY2VzLmF3c19jbG91ZGZyb250LklDYWNoZVBvbGljeVJlZiJ9")), "cachePolicy") unless @cache_policy.nil?
  @compress = compress
  Jsii::Type.check_type(@compress, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "compress") unless @compress.nil?
  @edge_lambdas = edge_lambdas.is_a?(Array) ? edge_lambdas.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::CloudFront::EdgeLambda.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : edge_lambdas
  Jsii::Type.check_type(@edge_lambdas, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19jbG91ZGZyb250LkVkZ2VMYW1iZGEifSwia2luZCI6ImFycmF5In19")), "edgeLambdas") unless @edge_lambdas.nil?
  @enable_grpc = enable_grpc
  Jsii::Type.check_type(@enable_grpc, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "enableGrpc") unless @enable_grpc.nil?
  @function_associations = function_associations.is_a?(Array) ? function_associations.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::CloudFront::FunctionAssociation.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : function_associations
  Jsii::Type.check_type(@function_associations, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19jbG91ZGZyb250LkZ1bmN0aW9uQXNzb2NpYXRpb24ifSwia2luZCI6ImFycmF5In19")), "functionAssociations") unless @function_associations.nil?
  @origin_request_policy = origin_request_policy
  Jsii::Type.check_type(@origin_request_policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5pbnRlcmZhY2VzLmF3c19jbG91ZGZyb250LklPcmlnaW5SZXF1ZXN0UG9saWN5UmVmIn0=")), "originRequestPolicy") unless @origin_request_policy.nil?
  @realtime_log_config = realtime_log_config
  Jsii::Type.check_type(@realtime_log_config, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5pbnRlcmZhY2VzLmF3c19jbG91ZGZyb250LklSZWFsdGltZUxvZ0NvbmZpZ1JlZiJ9")), "realtimeLogConfig") unless @realtime_log_config.nil?
  @response_headers_policy = response_headers_policy
  Jsii::Type.check_type(@response_headers_policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5pbnRlcmZhY2VzLmF3c19jbG91ZGZyb250LklSZXNwb25zZUhlYWRlcnNQb2xpY3lSZWYifQ==")), "responseHeadersPolicy") unless @response_headers_policy.nil?
  @smooth_streaming = smooth_streaming
  Jsii::Type.check_type(@smooth_streaming, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "smoothStreaming") unless @smooth_streaming.nil?
  @trusted_key_groups = trusted_key_groups
  Jsii::Type.check_type(@trusted_key_groups, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmludGVyZmFjZXMuYXdzX2Nsb3VkZnJvbnQuSUtleUdyb3VwUmVmIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "trustedKeyGroups") unless @trusted_key_groups.nil?
  @viewer_protocol_policy = viewer_protocol_policy
  Jsii::Type.check_type(@viewer_protocol_policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5WaWV3ZXJQcm90b2NvbFBvbGljeSJ9")), "viewerProtocolPolicy") unless @viewer_protocol_policy.nil?
end

Instance Attribute Details

#allowed_methodsAWSCDK::CloudFront::AllowedMethods? (readonly)

Note:

Default: AllowedMethods.ALLOW_GET_HEAD

HTTP methods to allow for this behavior.



53
54
55
# File 'cloud_front/add_behavior_options.rb', line 53

def allowed_methods
  @allowed_methods
end

#cache_policyAWSCDK::Interfaces::AWSCloudfront::ICachePolicyRef? (readonly)

Note:

Default: CachePolicy.CACHING_OPTIMIZED

The cache policy for this behavior.

The cache policy determines what values are included in the cache key, and the time-to-live (TTL) values for the cache.



67
68
69
# File 'cloud_front/add_behavior_options.rb', line 67

def cache_policy
  @cache_policy
end

#cached_methodsAWSCDK::CloudFront::CachedMethods? (readonly)

Note:

Default: CachedMethods.CACHE_GET_HEAD

HTTP methods to cache for this behavior.



58
59
60
# File 'cloud_front/add_behavior_options.rb', line 58

def cached_methods
  @cached_methods
end

#compressBoolean? (readonly)

Note:

Default: true

Whether you want CloudFront to automatically compress certain files for this cache behavior.

See https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html#compressed-content-cloudfront-file-types for file types CloudFront will compress.

Returns:

  • (Boolean, nil)


75
76
77
# File 'cloud_front/add_behavior_options.rb', line 75

def compress
  @compress
end

#edge_lambdasArray<AWSCDK::CloudFront::EdgeLambda>? (readonly)

Note:

Default: - no Lambda functions will be invoked

The Lambda@Edge functions to invoke before serving the contents.



81
82
83
# File 'cloud_front/add_behavior_options.rb', line 81

def edge_lambdas
  @edge_lambdas
end

#enable_grpcBoolean? (readonly)

Note:

Default: false

Enables your CloudFront distribution to receive gRPC requests and to proxy them directly to your origins.

If the enable_grpc is set to true, the following restrictions apply:

  • The allowed_methods property must be AllowedMethods.ALLOW_ALL to include POST method because gRPC only supports POST method.
  • The http_version property must be HttpVersion.HTTP2 or HttpVersion.HTTP2_AND_3 because gRPC only supports versions including HTTP/2.
  • The edge_lambdas property can't be specified because gRPC is not supported with Lambda@Edge.


93
94
95
# File 'cloud_front/add_behavior_options.rb', line 93

def enable_grpc
  @enable_grpc
end

#function_associationsArray<AWSCDK::CloudFront::FunctionAssociation>? (readonly)

Note:

Default: - no functions will be invoked

The CloudFront functions to invoke before serving the contents.



98
99
100
# File 'cloud_front/add_behavior_options.rb', line 98

def function_associations
  @function_associations
end

#origin_request_policyAWSCDK::Interfaces::AWSCloudfront::IOriginRequestPolicyRef? (readonly)

Note:

Default: - none

The origin request policy for this behavior.

The origin request policy determines which values (e.g., headers, cookies) are included in requests that CloudFront sends to the origin.



106
107
108
# File 'cloud_front/add_behavior_options.rb', line 106

def origin_request_policy
  @origin_request_policy
end

#realtime_log_configAWSCDK::Interfaces::AWSCloudfront::IRealtimeLogConfigRef? (readonly)

Note:

Default: - none

The real-time log configuration to be attached to this cache behavior.



111
112
113
# File 'cloud_front/add_behavior_options.rb', line 111

def realtime_log_config
  @realtime_log_config
end

#response_headers_policyAWSCDK::Interfaces::AWSCloudfront::IResponseHeadersPolicyRef? (readonly)

Note:

Default: - none

The response headers policy for this behavior.

The response headers policy determines which headers are included in responses



118
119
120
# File 'cloud_front/add_behavior_options.rb', line 118

def response_headers_policy
  @response_headers_policy
end

#smooth_streamingBoolean? (readonly)

Note:

Default: false

Set this to true to indicate you want to distribute media files in the Microsoft Smooth Streaming format using this behavior.

Returns:

  • (Boolean, nil)


123
124
125
# File 'cloud_front/add_behavior_options.rb', line 123

def smooth_streaming
  @smooth_streaming
end

#trusted_key_groupsArray<AWSCDK::Interfaces::AWSCloudfront::IKeyGroupRef>? (readonly)

Note:

Default: - no KeyGroups are associated with cache behavior

A list of Key Groups that CloudFront can use to validate signed URLs or signed cookies.



129
130
131
# File 'cloud_front/add_behavior_options.rb', line 129

def trusted_key_groups
  @trusted_key_groups
end

#viewer_protocol_policyAWSCDK::CloudFront::ViewerProtocolPolicy? (readonly)

Note:

Default: ViewerProtocolPolicy.ALLOW_ALL

The protocol that viewers can use to access the files controlled by this behavior.



134
135
136
# File 'cloud_front/add_behavior_options.rb', line 134

def viewer_protocol_policy
  @viewer_protocol_policy
end

Class Method Details

.jsii_propertiesObject



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'cloud_front/add_behavior_options.rb', line 136

def self.jsii_properties
  {
    :allowed_methods => "allowedMethods",
    :cached_methods => "cachedMethods",
    :cache_policy => "cachePolicy",
    :compress => "compress",
    :edge_lambdas => "edgeLambdas",
    :enable_grpc => "enableGrpc",
    :function_associations => "functionAssociations",
    :origin_request_policy => "originRequestPolicy",
    :realtime_log_config => "realtimeLogConfig",
    :response_headers_policy => "responseHeadersPolicy",
    :smooth_streaming => "smoothStreaming",
    :trusted_key_groups => "trustedKeyGroups",
    :viewer_protocol_policy => "viewerProtocolPolicy",
  }
end

Instance Method Details

#to_jsiiObject



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'cloud_front/add_behavior_options.rb', line 154

def to_jsii
  result = {}
  result.merge!({
    "allowedMethods" => @allowed_methods,
    "cachedMethods" => @cached_methods,
    "cachePolicy" => @cache_policy,
    "compress" => @compress,
    "edgeLambdas" => @edge_lambdas,
    "enableGrpc" => @enable_grpc,
    "functionAssociations" => @function_associations,
    "originRequestPolicy" => @origin_request_policy,
    "realtimeLogConfig" => @realtime_log_config,
    "responseHeadersPolicy" => @response_headers_policy,
    "smoothStreaming" => @smooth_streaming,
    "trustedKeyGroups" => @trusted_key_groups,
    "viewerProtocolPolicy" => @viewer_protocol_policy,
  })
  result.compact
end