Class CloudFrontWebDistribution
- All Implemented Interfaces:
IConstruct
,IDependable
,IResource
,IDistribution
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
CloudFront fronts user provided content and caches it at edge locations across the world.
Here's how you can use this construct:
Bucket sourceBucket = new Bucket(this, "Bucket"); CloudFrontWebDistribution distribution = CloudFrontWebDistribution.Builder.create(this, "MyDistribution") .originConfigs(List.of(SourceConfiguration.builder() .s3OriginSource(S3OriginConfig.builder() .s3BucketSource(sourceBucket) .build()) .behaviors(List.of(Behavior.builder().isDefaultBehavior(true).build())) .build())) .build();
This will create a CloudFront distribution that uses your S3Bucket as it's origin.
You can customize the distribution using additional properties from the CloudFrontWebDistributionProps interface.
Example:
Bucket sourceBucket; ViewerCertificate viewerCertificate = ViewerCertificate.fromIamCertificate("MYIAMROLEIDENTIFIER", ViewerCertificateOptions.builder() .aliases(List.of("MYALIAS")) .build()); CloudFrontWebDistribution.Builder.create(this, "MyCfWebDistribution") .originConfigs(List.of(SourceConfiguration.builder() .s3OriginSource(S3OriginConfig.builder() .s3BucketSource(sourceBucket) .build()) .behaviors(List.of(Behavior.builder().isDefaultBehavior(true).build())) .build())) .viewerCertificate(viewerCertificate) .build();
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A fluent builder forCloudFrontWebDistribution
.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.cloudfront.IDistribution
IDistribution.Jsii$Default, IDistribution.Jsii$Proxy
Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$Default
-
Constructor Summary
ModifierConstructorDescriptionprotected
CloudFrontWebDistribution
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CloudFrontWebDistribution
(software.amazon.jsii.JsiiObjectRef objRef) CloudFrontWebDistribution
(software.constructs.Construct scope, String id, CloudFrontWebDistributionProps props) -
Method Summary
Modifier and TypeMethodDescriptionstatic IDistribution
fromDistributionAttributes
(software.constructs.Construct scope, String id, CloudFrontWebDistributionAttributes attrs) Creates a construct that represents an external (imported) distribution.The domain name created by CloudFront for this distribution.The distribution ID for this distribution.Deprecated.The logging bucket for this CloudFront distribution.Methods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResource
Methods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
Methods inherited from class software.constructs.Construct
toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.amazon.awscdk.core.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStack
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
CloudFrontWebDistribution
protected CloudFrontWebDistribution(software.amazon.jsii.JsiiObjectRef objRef) -
CloudFrontWebDistribution
protected CloudFrontWebDistribution(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CloudFrontWebDistribution
@Stability(Stable) public CloudFrontWebDistribution(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CloudFrontWebDistributionProps props) - Parameters:
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.
-
-
Method Details
-
fromDistributionAttributes
@Stability(Stable) @NotNull public static IDistribution fromDistributionAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CloudFrontWebDistributionAttributes attrs) Creates a construct that represents an external (imported) distribution.- Parameters:
scope
- This parameter is required.id
- This parameter is required.attrs
- This parameter is required.
-
getDistributionDomainName
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.)
- Specified by:
getDistributionDomainName
in interfaceIDistribution
-
getDistributionId
The distribution ID for this distribution.- Specified by:
getDistributionId
in interfaceIDistribution
-
getDomainName
Deprecated.- Use
distributionDomainName
instead.
(deprecated) 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.)
- Specified by:
getDomainName
in interfaceIDistribution
- Use
-
getLoggingBucket
The logging bucket for this CloudFront distribution.If logging is not enabled for this distribution - this property will be undefined.
-
distributionDomainName
instead.