Class: AWSCDK::CloudFront::Behavior

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

Overview

A CloudFront behavior wrapper.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allowed_methods: nil, cached_methods: nil, compress: nil, default_ttl: nil, forwarded_values: nil, function_associations: nil, is_default_behavior: nil, lambda_function_associations: nil, max_ttl: nil, min_ttl: nil, path_pattern: nil, trusted_key_groups: nil, trusted_signers: nil, viewer_protocol_policy: nil) ⇒ Behavior

Returns a new instance of Behavior.

Parameters:

  • allowed_methods (AWSCDK::CloudFront::CloudFrontAllowedMethods, nil) (defaults to: nil)

    The method this CloudFront distribution responds do.

  • cached_methods (AWSCDK::CloudFront::CloudFrontAllowedCachedMethods, nil) (defaults to: nil)

    Which methods are cached by CloudFront by default.

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

    If CloudFront should automatically compress some content types.

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

    The default amount of time CloudFront will cache an object.

  • forwarded_values (AWSCDK::CloudFront::CfnDistribution::ForwardedValuesProperty, nil) (defaults to: nil)

    The values CloudFront will forward to the origin when making a request.

  • function_associations (Array<AWSCDK::CloudFront::FunctionAssociation>, nil) (defaults to: nil)

    The CloudFront functions to invoke before serving the contents.

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

    If this behavior is the default behavior for the distribution.

  • lambda_function_associations (Array<AWSCDK::CloudFront::LambdaFunctionAssociation>, nil) (defaults to: nil)

    Declares associated lambda@edge functions for this distribution behaviour.

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

    The max amount of time you want objects to stay in the cache before CloudFront queries your origin.

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

    The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin.

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

    The path this behavior responds to.

  • trusted_key_groups (Array<AWSCDK::Interfaces::AWSCloudfront::IKeyGroupRef>, nil) (defaults to: nil)

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

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

    Trusted signers is how CloudFront allows you to serve private content.

  • viewer_protocol_policy (AWSCDK::CloudFront::ViewerProtocolPolicy, nil) (defaults to: nil)

    The viewer policy for this behavior.



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
48
49
50
# File 'cloud_front/behavior.rb', line 21

def initialize(allowed_methods: nil, cached_methods: nil, compress: nil, default_ttl: nil, forwarded_values: nil, function_associations: nil, is_default_behavior: nil, lambda_function_associations: nil, max_ttl: nil, min_ttl: nil, path_pattern: nil, trusted_key_groups: nil, trusted_signers: nil, viewer_protocol_policy: nil)
  @allowed_methods = allowed_methods
  Jsii::Type.check_type(@allowed_methods, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5DbG91ZEZyb250QWxsb3dlZE1ldGhvZHMifQ==")), "allowedMethods") unless @allowed_methods.nil?
  @cached_methods = cached_methods
  Jsii::Type.check_type(@cached_methods, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5DbG91ZEZyb250QWxsb3dlZENhY2hlZE1ldGhvZHMifQ==")), "cachedMethods") unless @cached_methods.nil?
  @compress = compress
  Jsii::Type.check_type(@compress, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "compress") unless @compress.nil?
  @default_ttl = default_ttl
  Jsii::Type.check_type(@default_ttl, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "defaultTtl") unless @default_ttl.nil?
  @forwarded_values = forwarded_values.is_a?(Hash) ? ::AWSCDK::CloudFront::CfnDistribution::ForwardedValuesProperty.new(**forwarded_values.transform_keys(&:to_sym)) : forwarded_values
  Jsii::Type.check_type(@forwarded_values, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5DZm5EaXN0cmlidXRpb24uRm9yd2FyZGVkVmFsdWVzUHJvcGVydHkifQ==")), "forwardedValues") unless @forwarded_values.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?
  @is_default_behavior = is_default_behavior
  Jsii::Type.check_type(@is_default_behavior, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "isDefaultBehavior") unless @is_default_behavior.nil?
  @lambda_function_associations = lambda_function_associations.is_a?(Array) ? lambda_function_associations.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::CloudFront::LambdaFunctionAssociation.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : lambda_function_associations
  Jsii::Type.check_type(@lambda_function_associations, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19jbG91ZGZyb250LkxhbWJkYUZ1bmN0aW9uQXNzb2NpYXRpb24ifSwia2luZCI6ImFycmF5In19")), "lambdaFunctionAssociations") unless @lambda_function_associations.nil?
  @max_ttl = max_ttl
  Jsii::Type.check_type(@max_ttl, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "maxTtl") unless @max_ttl.nil?
  @min_ttl = min_ttl
  Jsii::Type.check_type(@min_ttl, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "minTtl") unless @min_ttl.nil?
  @path_pattern = path_pattern
  Jsii::Type.check_type(@path_pattern, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "pathPattern") unless @path_pattern.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?
  @trusted_signers = trusted_signers
  Jsii::Type.check_type(@trusted_signers, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "trustedSigners") unless @trusted_signers.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::CloudFrontAllowedMethods? (readonly)

Note:

Default: GET_HEAD

The method this CloudFront distribution responds do.



56
57
58
# File 'cloud_front/behavior.rb', line 56

def allowed_methods
  @allowed_methods
end

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

Note:

Default: GET_HEAD

Which methods are cached by CloudFront by default.



61
62
63
# File 'cloud_front/behavior.rb', line 61

def cached_methods
  @cached_methods
end

#compressBoolean? (readonly)

Note:

Default: true

If CloudFront should automatically compress some content types.

Returns:

  • (Boolean, nil)


66
67
68
# File 'cloud_front/behavior.rb', line 66

def compress
  @compress
end

#default_ttlAWSCDK::Duration? (readonly)

Note:

Default: 86400 (1 day)

The default amount of time CloudFront will cache an object.

This value applies only when your custom origin does not add HTTP headers, such as Cache-Control max-age, Cache-Control s-maxage, and Expires to objects.

Returns:



74
75
76
# File 'cloud_front/behavior.rb', line 74

def default_ttl
  @default_ttl
end

#forwarded_valuesAWSCDK::CloudFront::CfnDistribution::ForwardedValuesProperty? (readonly)

Note:

Default: none (no cookies - no headers)

The values CloudFront will forward to the origin when making a request.



79
80
81
# File 'cloud_front/behavior.rb', line 79

def forwarded_values
  @forwarded_values
end

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

Note:

Default: - no functions will be invoked

The CloudFront functions to invoke before serving the contents.



84
85
86
# File 'cloud_front/behavior.rb', line 84

def function_associations
  @function_associations
end

#is_default_behaviorBoolean? (readonly)

If this behavior is the default behavior for the distribution.

You must specify exactly one default distribution per CloudFront distribution. The default behavior is allowed to omit the "path" property.

Returns:

  • (Boolean, nil)


91
92
93
# File 'cloud_front/behavior.rb', line 91

def is_default_behavior
  @is_default_behavior
end

#lambda_function_associationsArray<AWSCDK::CloudFront::LambdaFunctionAssociation>? (readonly)

Note:

Default: No lambda function associated

Declares associated lambda@edge functions for this distribution behaviour.



96
97
98
# File 'cloud_front/behavior.rb', line 96

def lambda_function_associations
  @lambda_function_associations
end

#max_ttlAWSCDK::Duration? (readonly)

Note:

Default: Duration.seconds(31536000) (one year)

The max amount of time you want objects to stay in the cache before CloudFront queries your origin.

Returns:



101
102
103
# File 'cloud_front/behavior.rb', line 101

def max_ttl
  @max_ttl
end

#min_ttlAWSCDK::Duration? (readonly)

The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin.

Returns:



105
106
107
# File 'cloud_front/behavior.rb', line 105

def min_ttl
  @min_ttl
end

#path_patternString? (readonly)

The path this behavior responds to.

Required for all non-default behaviors. (The default behavior implicitly has "*" as the path pattern. )

Returns:

  • (String, nil)


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

def path_pattern
  @path_pattern
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.



117
118
119
# File 'cloud_front/behavior.rb', line 117

def trusted_key_groups
  @trusted_key_groups
end

#trusted_signersArray<String>? (readonly)

Deprecated.
  • We recommend using trustedKeyGroups instead of trustedSigners.

Trusted signers is how CloudFront allows you to serve private content.

The signers are the account IDs that are allowed to sign cookies/presigned URLs for this distribution.

If you pass a non empty value, all requests for this behavior must be signed (no public access will be allowed)

Returns:

  • (Array<String>, nil)


126
127
128
# File 'cloud_front/behavior.rb', line 126

def trusted_signers
  @trusted_signers
end

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

Note:

Default: - the distribution wide viewer protocol policy will be used

The viewer policy for this behavior.



131
132
133
# File 'cloud_front/behavior.rb', line 131

def viewer_protocol_policy
  @viewer_protocol_policy
end

Class Method Details

.jsii_propertiesObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'cloud_front/behavior.rb', line 133

def self.jsii_properties
  {
    :allowed_methods => "allowedMethods",
    :cached_methods => "cachedMethods",
    :compress => "compress",
    :default_ttl => "defaultTtl",
    :forwarded_values => "forwardedValues",
    :function_associations => "functionAssociations",
    :is_default_behavior => "isDefaultBehavior",
    :lambda_function_associations => "lambdaFunctionAssociations",
    :max_ttl => "maxTtl",
    :min_ttl => "minTtl",
    :path_pattern => "pathPattern",
    :trusted_key_groups => "trustedKeyGroups",
    :trusted_signers => "trustedSigners",
    :viewer_protocol_policy => "viewerProtocolPolicy",
  }
end

Instance Method Details

#to_jsiiObject



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

def to_jsii
  result = {}
  result.merge!({
    "allowedMethods" => @allowed_methods,
    "cachedMethods" => @cached_methods,
    "compress" => @compress,
    "defaultTtl" => @default_ttl,
    "forwardedValues" => @forwarded_values,
    "functionAssociations" => @function_associations,
    "isDefaultBehavior" => @is_default_behavior,
    "lambdaFunctionAssociations" => @lambda_function_associations,
    "maxTtl" => @max_ttl,
    "minTtl" => @min_ttl,
    "pathPattern" => @path_pattern,
    "trustedKeyGroups" => @trusted_key_groups,
    "trustedSigners" => @trusted_signers,
    "viewerProtocolPolicy" => @viewer_protocol_policy,
  })
  result.compact
end