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
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent builder forCloudFrontWebDistribution.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.cloudfront.IDistribution
IDistribution.Jsii$Default, IDistribution.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCloudFrontWebDistribution(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCloudFrontWebDistribution(software.amazon.jsii.JsiiObjectRef objRef) CloudFrontWebDistribution(software.constructs.Construct scope, String id, CloudFrontWebDistributionProps props) -
Method Summary
Modifier and TypeMethodDescriptionstatic IDistributionfromDistributionAttributes(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, isResourceMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.constructs.Construct
toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.core.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.core.IResource
applyRemovalPolicy, getEnv, getStackMethods 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:
getDistributionDomainNamein interfaceIDistribution
-
getDistributionId
The distribution ID for this distribution.- Specified by:
getDistributionIdin interfaceIDistribution
-
getDomainName
Deprecated.- Use
distributionDomainNameinstead.
(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:
getDomainNamein interfaceIDistribution
- Use
-
getLoggingBucket
The logging bucket for this CloudFront distribution.If logging is not enabled for this distribution - this property will be undefined.
-
distributionDomainNameinstead.