Class: AWSCDK::CloudFront::CloudFrontWebDistribution Deprecated
- Inherits:
-
Resource
- Object
- Resource
- AWSCDK::CloudFront::CloudFrontWebDistribution
- Includes:
- IDistribution
- Defined in:
- cloud_front/cloud_front_web_distribution.rb
Overview
Use Distribution instead
Amazon CloudFront is a global content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to your viewers with low latency and high transfer speeds.
CloudFront fronts user provided content and caches it at edge locations across the world.
Here's how you can use this construct:
source_bucket = AWSCDK::S3::Bucket.new(self, "Bucket")
distribution = AWSCDK::CloudFront::CloudFrontWebDistribution.new(self, "MyDistribution", {
origin_configs: [
{
s3_origin_source: {
s3_bucket_source: source_bucket,
},
behaviors: [{is_default_behavior: true}],
},
],
})
This will create a CloudFront distribution that uses your S3Bucket as its origin.
You can customize the distribution using additional properties from the CloudFrontWebDistributionProps interface.
Class Method Summary collapse
-
.from_distribution_attributes(scope, id, attrs) ⇒ AWSCDK::CloudFront::IDistribution
Creates a construct that represents an external (imported) distribution.
- .jsii_overridable_methods ⇒ Object
-
.PROPERTY_INJECTION_ID ⇒ String
Uniquely identifies this class.
Instance Method Summary collapse
-
#apply_cross_stack_reference_strength(strength) ⇒ void
Override the cross-stack reference strength for this resource.
-
#apply_removal_policy(policy) ⇒ void
Apply the given removal policy to this resource.
-
#distribution_arn ⇒ String
The distribution ARN for this distribution.
-
#distribution_domain_name ⇒ String
The domain name created by CloudFront for this distribution.
-
#distribution_id ⇒ String
The distribution ID for this distribution.
-
#distribution_ref ⇒ AWSCDK::Interfaces::AWSCloudfront::DistributionReference
A reference to a Distribution resource.
-
#env ⇒ AWSCDK::Interfaces::ResourceEnvironment
The environment this resource belongs to.
- #generate_physical_name ⇒ String
-
#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). -
#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). -
#grant(identity, *actions) ⇒ AWSCDK::IAM::Grant
Adds an IAM policy statement associated with this distribution to an IAM principal's policy.
-
#grant_create_invalidation(identity) ⇒ AWSCDK::IAM::Grant
Grant to create invalidations for this bucket to an IAM principal (Role/Group/User).
-
#grants ⇒ AWSCDK::CloudFront::DistributionGrants
Collection of grant methods for a Distribution.
-
#initialize(scope, id, props) ⇒ CloudFrontWebDistribution
constructor
A new instance of CloudFrontWebDistribution.
-
#logging_bucket ⇒ AWSCDK::S3::IBucket?
The logging bucket for this CloudFront distribution.
-
#node ⇒ Constructs::Node
The tree node.
-
#physical_name ⇒ String
Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.
-
#stack ⇒ AWSCDK::Stack
The stack in which this resource is defined.
-
#to_string ⇒ String
Returns a string representation of this construct.
-
#with(*mixins) ⇒ Constructs::IConstruct
Applies one or more mixins to this construct.
Constructor Details
#initialize(scope, id, props) ⇒ CloudFrontWebDistribution
Returns a new instance of CloudFrontWebDistribution.
37 38 39 40 41 42 43 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 37 def initialize(scope, id, props) props = props.is_a?(Hash) ? ::AWSCDK::CloudFront::CloudFrontWebDistributionProps.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("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5DbG91ZEZyb250V2ViRGlzdHJpYnV0aW9uUHJvcHMifQ==")), "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 construct that represents an external (imported) distribution.
75 76 77 78 79 80 81 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 75 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::CloudFrontWebDistributionAttributes.new(**attrs.transform_keys(&:to_sym)) : attrs Jsii::Type.check_type(attrs, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY2xvdWRmcm9udC5DbG91ZEZyb250V2ViRGlzdHJpYnV0aW9uQXR0cmlidXRlcyJ9")), "attrs") Jsii::Kernel.instance.call_static("aws-cdk-lib.aws_cloudfront.CloudFrontWebDistribution", "fromDistributionAttributes", [scope, id, attrs]) end |
.jsii_overridable_methods ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 45 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 }, :grants => { kind: :property, name: "grants", is_optional: false }, :logging_bucket => { kind: :property, name: "loggingBucket", is_optional: true }, :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 }, :grant => { kind: :method, name: "grant", is_optional: false }, :grant_create_invalidation => { kind: :method, name: "grantCreateInvalidation", is_optional: false }, } end |
.PROPERTY_INJECTION_ID ⇒ String
Uniquely identifies this class.
129 130 131 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 129 def self.PROPERTY_INJECTION_ID() Jsii::Kernel.instance.get_static("aws-cdk-lib.aws_cloudfront.CloudFrontWebDistribution", "PROPERTY_INJECTION_ID") end |
Instance Method Details
#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.
213 214 215 216 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 213 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).
230 231 232 233 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 230 def apply_removal_policy(policy) Jsii::Type.check_type(policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5SZW1vdmFsUG9saWN5In0=")), "policy") jsii_call_method("applyRemovalPolicy", [policy]) end |
#distribution_arn ⇒ String
The distribution ARN for this distribution.
136 137 138 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 136 def distribution_arn() jsii_get_property("distributionArn") end |
#distribution_domain_name ⇒ String
The domain name created by CloudFront for this distribution.
If you are using aliases for your distribution, this is the domainName your DNS records should point to. (In Route53, you could create an ALIAS record to this value, for example.)
146 147 148 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 146 def distribution_domain_name() jsii_get_property("distributionDomainName") end |
#distribution_id ⇒ String
The distribution ID for this distribution.
153 154 155 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 153 def distribution_id() jsii_get_property("distributionId") end |
#distribution_ref ⇒ AWSCDK::Interfaces::AWSCloudfront::DistributionReference
A reference to a Distribution resource.
160 161 162 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 160 def distribution_ref() jsii_get_property("distributionRef") end |
#env ⇒ AWSCDK::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.
101 102 103 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 101 def env() jsii_get_property("env") end |
#generate_physical_name ⇒ String
236 237 238 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 236 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.
250 251 252 253 254 255 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 250 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.
265 266 267 268 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 265 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]
277 278 279 280 281 282 283 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 277 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]
291 292 293 294 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 291 def grant_create_invalidation(identity) Jsii::Type.check_type(identity, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "identity") jsii_call_method("grantCreateInvalidation", [identity]) end |
#grants ⇒ AWSCDK::CloudFront::DistributionGrants
Collection of grant methods for a Distribution.
167 168 169 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 167 def grants() jsii_get_property("grants") end |
#logging_bucket ⇒ AWSCDK::S3::IBucket?
The logging bucket for this CloudFront distribution.
If logging is not enabled for this distribution - this property will be undefined.
176 177 178 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 176 def logging_bucket() jsii_get_property("loggingBucket") end |
#node ⇒ Constructs::Node
The tree node.
86 87 88 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 86 def node() jsii_get_property("node") end |
#physical_name ⇒ String
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.
115 116 117 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 115 def physical_name() jsii_get_property("physicalName") end |
#stack ⇒ AWSCDK::Stack
The stack in which this resource is defined.
122 123 124 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 122 def stack() jsii_get_property("stack") end |
#to_string ⇒ String
Returns a string representation of this construct.
183 184 185 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 183 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.
196 197 198 199 200 201 |
# File 'cloud_front/cloud_front_web_distribution.rb', line 196 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 |