Class: AWSCDK::CloudFront::Distribution

Inherits:
Resource
  • Object
show all
Includes:
IDistribution
Defined in:
cloud_front/distribution.rb

Overview

A CloudFront distribution with associated origin(s) and caching behavior(s).

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, id, props) ⇒ Distribution

Returns a new instance of Distribution.

Parameters:



12
13
14
15
16
17
18
# File 'cloud_front/distribution.rb', line 12

def initialize(scope, id, props)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudFront::DistributionProps.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5EaXN0cmlidXRpb25Qcm9wcyJ9")), "props")
  Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props)
end

Class Method Details

.from_distribution_attributes(scope, id, attrs) ⇒ AWSCDK::CloudFront::IDistribution

Creates a Distribution construct that represents an external (imported) distribution.

Parameters:

Returns:



67
68
69
70
71
72
73
# File 'cloud_front/distribution.rb', line 67

def self.from_distribution_attributes(scope, id, attrs)
  Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope")
  Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id")
  attrs = attrs.is_a?(Hash) ? ::AWSCDK::CloudFront::DistributionAttributes.new(**attrs.transform_keys(&:to_sym)) : attrs
  Jsii::Type.check_type(attrs, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5EaXN0cmlidXRpb25BdHRyaWJ1dGVzIn0=")), "attrs")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_cloudfront.Distribution", "fromDistributionAttributes", [scope, id, attrs])
end

.jsii_overridable_methodsObject



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
48
49
50
51
52
53
54
55
56
57
58
59
# File 'cloud_front/distribution.rb', line 20

def self.jsii_overridable_methods
  {
    :node => { kind: :property, name: "node", is_optional: false },
    :env => { kind: :property, name: "env", is_optional: false },
    :physical_name => { kind: :property, name: "physicalName", is_optional: false },
    :stack => { kind: :property, name: "stack", is_optional: false },
    :distribution_arn => { kind: :property, name: "distributionArn", is_optional: false },
    :distribution_domain_name => { kind: :property, name: "distributionDomainName", is_optional: false },
    :distribution_id => { kind: :property, name: "distributionId", is_optional: false },
    :distribution_ref => { kind: :property, name: "distributionRef", is_optional: false },
    :domain_name => { kind: :property, name: "domainName", is_optional: false },
    :grants => { kind: :property, name: "grants", is_optional: false },
    :to_string => { kind: :method, name: "toString", is_optional: false },
    :with => { kind: :method, name: "with", is_optional: false },
    :apply_cross_stack_reference_strength => { kind: :method, name: "applyCrossStackReferenceStrength", is_optional: false },
    :apply_removal_policy => { kind: :method, name: "applyRemovalPolicy", is_optional: false },
    :generate_physical_name => { kind: :method, name: "generatePhysicalName", is_optional: false },
    :get_resource_arn_attribute => { kind: :method, name: "getResourceArnAttribute", is_optional: false },
    :get_resource_name_attribute => { kind: :method, name: "getResourceNameAttribute", is_optional: false },
    :add_behavior => { kind: :method, name: "addBehavior", is_optional: false },
    :attach_web_acl_id => { kind: :method, name: "attachWebAclId", is_optional: false },
    :grant => { kind: :method, name: "grant", is_optional: false },
    :grant_create_invalidation => { kind: :method, name: "grantCreateInvalidation", is_optional: false },
    :metric => { kind: :method, name: "metric", is_optional: false },
    :metric401_error_rate => { kind: :method, name: "metric401ErrorRate", is_optional: false },
    :metric403_error_rate => { kind: :method, name: "metric403ErrorRate", is_optional: false },
    :metric404_error_rate => { kind: :method, name: "metric404ErrorRate", is_optional: false },
    :metric4xx_error_rate => { kind: :method, name: "metric4xxErrorRate", is_optional: false },
    :metric502_error_rate => { kind: :method, name: "metric502ErrorRate", is_optional: false },
    :metric503_error_rate => { kind: :method, name: "metric503ErrorRate", is_optional: false },
    :metric504_error_rate => { kind: :method, name: "metric504ErrorRate", is_optional: false },
    :metric5xx_error_rate => { kind: :method, name: "metric5xxErrorRate", is_optional: false },
    :metric_bytes_downloaded => { kind: :method, name: "metricBytesDownloaded", is_optional: false },
    :metric_bytes_uploaded => { kind: :method, name: "metricBytesUploaded", is_optional: false },
    :metric_cache_hit_rate => { kind: :method, name: "metricCacheHitRate", is_optional: false },
    :metric_origin_latency => { kind: :method, name: "metricOriginLatency", is_optional: false },
    :metric_requests => { kind: :method, name: "metricRequests", is_optional: false },
    :metric_total_error_rate => { kind: :method, name: "metricTotalErrorRate", is_optional: false },
  }
end

.PROPERTY_INJECTION_IDString

Uniquely identifies this class.

Returns:

  • (String)


121
122
123
# File 'cloud_front/distribution.rb', line 121

def self.PROPERTY_INJECTION_ID()
  Jsii::Kernel.instance.get_static("aws-cdk-lib.aws_cloudfront.Distribution", "PROPERTY_INJECTION_ID")
end

Instance Method Details

#add_behavior(path_pattern, origin, behavior_options = nil) ⇒ void

This method returns an undefined value.

Adds a new behavior to this distribution for the given pathPattern.

Parameters:

  • path_pattern (String)

    the path pattern (e.g., 'images/*') that specifies which requests to apply the behavior to.

  • origin (AWSCDK::CloudFront::IOrigin)

    the origin to use for this behavior.

  • behavior_options (AWSCDK::CloudFront::AddBehaviorOptions, nil) (defaults to: nil)

    the options for the behavior at this path.



263
264
265
266
267
268
269
# File 'cloud_front/distribution.rb', line 263

def add_behavior(path_pattern, origin, behavior_options = nil)
  Jsii::Type.check_type(path_pattern, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "pathPattern")
  Jsii::Type.check_type(origin, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5JT3JpZ2luIn0=")), "origin")
  behavior_options = behavior_options.is_a?(Hash) ? ::AWSCDK::CloudFront::AddBehaviorOptions.new(**behavior_options.transform_keys(&:to_sym)) : behavior_options
  Jsii::Type.check_type(behavior_options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5BZGRCZWhhdmlvck9wdGlvbnMifQ==")), "behaviorOptions") unless behavior_options.nil?
  jsii_call_method("addBehavior", [path_pattern, origin, behavior_options])
end

#apply_cross_stack_reference_strength(strength) ⇒ void

This method returns an undefined value.

Override the cross-stack reference strength for this resource.

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters:



200
201
202
203
# File 'cloud_front/distribution.rb', line 200

def apply_cross_stack_reference_strength(strength)
  Jsii::Type.check_type(strength, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZWZlcmVuY2VTdHJlbmd0aCJ9")), "strength")
  jsii_call_method("applyCrossStackReferenceStrength", [strength])
end

#apply_removal_policy(policy) ⇒ void

This method returns an undefined value.

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:



217
218
219
220
# File 'cloud_front/distribution.rb', line 217

def apply_removal_policy(policy)
  Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy")
  jsii_call_method("applyRemovalPolicy", [policy])
end

#attach_web_acl_id(web_acl_id) ⇒ void

This method returns an undefined value.

Attach WAF WebACL to this CloudFront distribution.

WebACL must be in the us-east-1 region

Parameters:

  • web_acl_id (String)

    The WAF WebACL to associate with this distribution.



277
278
279
280
# File 'cloud_front/distribution.rb', line 277

def attach_web_acl_id(web_acl_id)
  Jsii::Type.check_type(web_acl_id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "webAclId")
  jsii_call_method("attachWebAclId", [web_acl_id])
end

#distribution_arnString

The distribution ARN for this distribution.

Returns:

  • (String)


128
129
130
# File 'cloud_front/distribution.rb', line 128

def distribution_arn()
  jsii_get_property("distributionArn")
end

#distribution_domain_nameString

The domain name of the Distribution, such as d111111abcdef8.cloudfront.net.

Returns:

  • (String)


135
136
137
# File 'cloud_front/distribution.rb', line 135

def distribution_domain_name()
  jsii_get_property("distributionDomainName")
end

#distribution_idString

The distribution ID for this distribution.

Returns:

  • (String)


142
143
144
# File 'cloud_front/distribution.rb', line 142

def distribution_id()
  jsii_get_property("distributionId")
end

#distribution_refAWSCDK::Interfaces::AWSCloudfront::DistributionReference

A reference to a Distribution resource.



149
150
151
# File 'cloud_front/distribution.rb', line 149

def distribution_ref()
  jsii_get_property("distributionRef")
end

#domain_nameString

The domain name of the Distribution, such as d111111abcdef8.cloudfront.net.

Returns:

  • (String)


156
157
158
# File 'cloud_front/distribution.rb', line 156

def domain_name()
  jsii_get_property("domainName")
end

#envAWSCDK::Interfaces::ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.



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

def env()
  jsii_get_property("env")
end

#generate_physical_nameString

Returns:

  • (String)


223
224
225
# File 'cloud_front/distribution.rb', line 223

def generate_physical_name()
  jsii_call_method("generatePhysicalName", [])
end

#get_resource_arn_attribute(arn_attr, arn_components) ⇒ String

Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. bucket.bucketArn).

Normally, this token will resolve to arn_attr, but if the resource is referenced across environments, arn_components will be used to synthesize a concrete ARN with the resource's physical name. Make sure to reference this.physicalName in arn_components.

Parameters:

  • arn_attr (String)

    The CFN attribute which resolves to the ARN of the resource.

  • arn_components (AWSCDK::ARNComponents)

    The format of the ARN of this resource.

Returns:

  • (String)


237
238
239
240
241
242
# File 'cloud_front/distribution.rb', line 237

def get_resource_arn_attribute(arn_attr, arn_components)
  Jsii::Type.check_type(arn_attr, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "arnAttr")
  arn_components = arn_components.is_a?(Hash) ? ::AWSCDK::ARNComponents.new(**arn_components.transform_keys(&:to_sym)) : arn_components
  Jsii::Type.check_type(arn_components, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Bcm5Db21wb25lbnRzIn0=")), "arnComponents")
  jsii_call_method("getResourceArnAttribute", [arn_attr, arn_components])
end

#get_resource_name_attribute(name_attr) ⇒ String

Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. bucket.bucketName).

Normally, this token will resolve to name_attr, but if the resource is referenced across environments, it will be resolved to this.physicalName, which will be a concrete name.

Parameters:

  • name_attr (String)

    The CFN attribute which resolves to the resource's name.

Returns:

  • (String)


252
253
254
255
# File 'cloud_front/distribution.rb', line 252

def get_resource_name_attribute(name_attr)
  Jsii::Type.check_type(name_attr, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "nameAttr")
  jsii_call_method("getResourceNameAttribute", [name_attr])
end

#grant(identity, *actions) ⇒ AWSCDK::IAM::Grant

Adds an IAM policy statement associated with this distribution to an IAM principal's policy.

[disable-awslint:no-grants]

Parameters:

  • identity (AWSCDK::IAM::IGrantable)

    The principal.

  • actions (Array<String>)

    The set of actions to allow (i.e. "cloudfront:ListInvalidations").

Returns:



289
290
291
292
293
294
295
# File 'cloud_front/distribution.rb', line 289

def grant(identity, *actions)
  Jsii::Type.check_type(identity, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "identity")
  actions.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "actions[#{index}]")
  end
  jsii_call_method("grant", [identity, *actions])
end

#grant_create_invalidation(identity) ⇒ AWSCDK::IAM::Grant

Grant to create invalidations for this bucket to an IAM principal (Role/Group/User).

[disable-awslint:no-grants]

Parameters:

Returns:



303
304
305
306
# File 'cloud_front/distribution.rb', line 303

def grant_create_invalidation(identity)
  Jsii::Type.check_type(identity, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "identity")
  jsii_call_method("grantCreateInvalidation", [identity])
end

#grantsAWSCDK::CloudFront::DistributionGrants

Collection of grant methods for a Distribution.



163
164
165
# File 'cloud_front/distribution.rb', line 163

def grants()
  jsii_get_property("grants")
end

#metric(metric_name, props = nil) ⇒ AWSCDK::CloudWatch::Metric

Return the given named metric for this Distribution.

Parameters:

Returns:



313
314
315
316
317
318
# File 'cloud_front/distribution.rb', line 313

def metric(metric_name, props = nil)
  Jsii::Type.check_type(metric_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "metricName")
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric", [metric_name, props])
end

#metric401_error_rate(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - average over 5 minutes

Metric for the percentage of all viewer requests for which the response's HTTP status code is 401.

To obtain this metric, you need to set publish_additional_metrics to true.

Parameters:

Returns:



327
328
329
330
331
# File 'cloud_front/distribution.rb', line 327

def metric401_error_rate(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric401ErrorRate", [props])
end

#metric403_error_rate(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - average over 5 minutes

Metric for the percentage of all viewer requests for which the response's HTTP status code is 403.

To obtain this metric, you need to set publish_additional_metrics to true.

Parameters:

Returns:



340
341
342
343
344
# File 'cloud_front/distribution.rb', line 340

def metric403_error_rate(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric403ErrorRate", [props])
end

#metric404_error_rate(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - average over 5 minutes

Metric for the percentage of all viewer requests for which the response's HTTP status code is 404.

To obtain this metric, you need to set publish_additional_metrics to true.

Parameters:

Returns:



353
354
355
356
357
# File 'cloud_front/distribution.rb', line 353

def metric404_error_rate(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric404ErrorRate", [props])
end

#metric4xx_error_rate(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - average over 5 minutes

Metric for the percentage of all viewer requests for which the response's HTTP status code is 4xx.

Parameters:

Returns:



364
365
366
367
368
# File 'cloud_front/distribution.rb', line 364

def metric4xx_error_rate(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric4xxErrorRate", [props])
end

#metric502_error_rate(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - average over 5 minutes

Metric for the percentage of all viewer requests for which the response's HTTP status code is 502.

To obtain this metric, you need to set publish_additional_metrics to true.

Parameters:

Returns:



377
378
379
380
381
# File 'cloud_front/distribution.rb', line 377

def metric502_error_rate(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric502ErrorRate", [props])
end

#metric503_error_rate(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - average over 5 minutes

Metric for the percentage of all viewer requests for which the response's HTTP status code is 503.

To obtain this metric, you need to set publish_additional_metrics to true.

Parameters:

Returns:



390
391
392
393
394
# File 'cloud_front/distribution.rb', line 390

def metric503_error_rate(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric503ErrorRate", [props])
end

#metric504_error_rate(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - average over 5 minutes

Metric for the percentage of all viewer requests for which the response's HTTP status code is 504.

To obtain this metric, you need to set publish_additional_metrics to true.

Parameters:

Returns:



403
404
405
406
407
# File 'cloud_front/distribution.rb', line 403

def metric504_error_rate(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric504ErrorRate", [props])
end

#metric5xx_error_rate(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - average over 5 minutes

Metric for the percentage of all viewer requests for which the response's HTTP status code is 5xx.

Parameters:

Returns:



414
415
416
417
418
# File 'cloud_front/distribution.rb', line 414

def metric5xx_error_rate(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metric5xxErrorRate", [props])
end

#metric_bytes_downloaded(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - sum over 5 minutes

Metric for the total number of bytes downloaded by viewers for GET, HEAD, and OPTIONS requests.

Parameters:

Returns:



425
426
427
428
429
# File 'cloud_front/distribution.rb', line 425

def metric_bytes_downloaded(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricBytesDownloaded", [props])
end

#metric_bytes_uploaded(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - sum over 5 minutes

Metric for the total number of bytes that viewers uploaded to your origin with CloudFront, using POST and PUT requests.

Parameters:

Returns:



436
437
438
439
440
# File 'cloud_front/distribution.rb', line 436

def metric_bytes_uploaded(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricBytesUploaded", [props])
end

#metric_cache_hit_rate(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - average over 5 minutes

Metric for the percentage of all cacheable requests for which CloudFront served the content from its cache.

HTTP POST and PUT requests, and errors, are not considered cacheable requests.

To obtain this metric, you need to set publish_additional_metrics to true.

Parameters:

Returns:



451
452
453
454
455
# File 'cloud_front/distribution.rb', line 451

def metric_cache_hit_rate(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricCacheHitRate", [props])
end

#metric_origin_latency(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - average over 5 minutes

Metric for the total time spent from when CloudFront receives a request to when it starts providing a response to the network (not the viewer), for requests that are served from the origin, not the CloudFront cache.

This is also known as first byte latency, or time-to-first-byte.

To obtain this metric, you need to set publish_additional_metrics to true.

Parameters:

Returns:



466
467
468
469
470
# File 'cloud_front/distribution.rb', line 466

def metric_origin_latency(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricOriginLatency", [props])
end

#metric_requests(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - sum over 5 minutes

Metric for the total number of viewer requests received by CloudFront, for all HTTP methods and for both HTTP and HTTPS requests.

Parameters:

Returns:



477
478
479
480
481
# File 'cloud_front/distribution.rb', line 477

def metric_requests(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricRequests", [props])
end

#metric_total_error_rate(props = nil) ⇒ AWSCDK::CloudWatch::Metric

Note:

Default: - average over 5 minutes

Metric for the percentage of all viewer requests for which the response's HTTP status code is 4xx or 5xx.

Parameters:

Returns:



488
489
490
491
492
# File 'cloud_front/distribution.rb', line 488

def metric_total_error_rate(props = nil)
  props = props.is_a?(Hash) ? ::AWSCDK::CloudWatch::MetricOptions.new(**props.transform_keys(&:to_sym)) : props
  Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWR3YXRjaC5NZXRyaWNPcHRpb25zIn0=")), "props") unless props.nil?
  jsii_call_method("metricTotalErrorRate", [props])
end

#nodeConstructs::Node

The tree node.

Returns:

  • (Constructs::Node)


78
79
80
# File 'cloud_front/distribution.rb', line 78

def node()
  jsii_get_property("node")
end

#physical_nameString

Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.

This value will resolve to one of the following:

  • a concrete value (e.g. "my-awesome-bucket")
  • undefined, when a name should be generated by CloudFormation
  • a concrete name generated automatically during synthesis, in cross-environment scenarios.

Returns:

  • (String)


107
108
109
# File 'cloud_front/distribution.rb', line 107

def physical_name()
  jsii_get_property("physicalName")
end

#stackAWSCDK::Stack

The stack in which this resource is defined.

Returns:



114
115
116
# File 'cloud_front/distribution.rb', line 114

def stack()
  jsii_get_property("stack")
end

#to_stringString

Returns a string representation of this construct.

Returns:

  • (String)


170
171
172
# File 'cloud_front/distribution.rb', line 170

def to_string()
  jsii_call_method("toString", [])
end

#with(*mixins) ⇒ Constructs::IConstruct

Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

Parameters:

  • mixins (Array<Constructs::IMixin>)

Returns:

  • (Constructs::IConstruct)


183
184
185
186
187
188
# File 'cloud_front/distribution.rb', line 183

def with(*mixins)
  mixins.each_with_index do |item, index|
    Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]")
  end
  jsii_call_method("with", [*mixins])
end