Class CfnDistribution
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.CfnElement
software.amazon.awscdk.CfnRefElement
software.amazon.awscdk.CfnResource
software.amazon.awscdk.services.cloudfront.CfnDistribution
- All Implemented Interfaces:
IInspectable,IDistributionRef,IEnvironmentAware,ITaggable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.119.0 (build 1634eac)",
date="2025-11-20T23:37:16.245Z")
@Stability(Stable)
public class CfnDistribution
extends CfnResource
implements IInspectable, IDistributionRef, ITaggable
A distribution tells CloudFront where you want content to be delivered from, and the details about how to track and manage content delivery.
Example:
// Create the simple Origin
Bucket myBucket = new Bucket(this, "myBucket");
IOrigin s3Origin = S3BucketOrigin.withOriginAccessControl(myBucket, S3BucketOriginWithOACProps.builder()
.originAccessLevels(List.of(AccessLevel.READ, AccessLevel.LIST))
.build());
// Create the Distribution construct
Distribution myMultiTenantDistribution = Distribution.Builder.create(this, "distribution")
.defaultBehavior(BehaviorOptions.builder()
.origin(s3Origin)
.build())
.defaultRootObject("index.html")
.build();
// Access the underlying L1 CfnDistribution to configure SaaS Manager properties which are not yet available in the L2 Distribution construct
CfnDistribution cfnDistribution = (CfnDistribution)myMultiTenantDistribution.getNode().getDefaultChild();
DefaultCacheBehaviorProperty defaultCacheBehavior = DefaultCacheBehaviorProperty.builder()
.targetOriginId(myBucket.getBucketArn())
.viewerProtocolPolicy("allow-all")
.compress(false)
.allowedMethods(List.of("GET", "HEAD"))
.cachePolicyId(CachePolicy.CACHING_OPTIMIZED.getCachePolicyId())
.build();
// Create the updated distributionConfig
DistributionConfigProperty distributionConfig = DistributionConfigProperty.builder()
.defaultCacheBehavior(defaultCacheBehavior)
.enabled(true)
// the properties below are optional
.connectionMode("tenant-only")
.origins(List.of(OriginProperty.builder()
.id(myBucket.getBucketArn())
.domainName(myBucket.getBucketDomainName())
.s3OriginConfig(S3OriginConfigProperty.builder().build())
.originPath("/{{tenantName}}")
.build()))
.tenantConfig(TenantConfigProperty.builder()
.parameterDefinitions(List.of(ParameterDefinitionProperty.builder()
.definition(DefinitionProperty.builder()
.stringSchema(StringSchemaProperty.builder()
.required(false)
// the properties below are optional
.comment("tenantName")
.defaultValue("root")
.build())
.build())
.name("tenantName")
.build()))
.build())
.build();
// Override the distribution configuration to enable multi-tenancy.
cfnDistribution.getDistributionConfig() = distributionConfig;
// Create a distribution tenant using an existing ACM certificate
CfnDistributionTenant cfnDistributionTenant = CfnDistributionTenant.Builder.create(this, "distribution-tenant")
.distributionId(myMultiTenantDistribution.getDistributionId())
.domains(List.of("my-tenant.my.domain.com"))
.name("my-tenant")
.enabled(true)
.parameters(List.of(ParameterProperty.builder()
.name("tenantName")
.value("app")
.build()))
.customizations(CustomizationsProperty.builder()
.certificate(CertificateProperty.builder()
.arn("REPLACE_WITH_ARN")
.build())
.build())
.build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent builder forCfnDistribution.static interfaceA complex type that describes how CloudFront processes requests.static interfaceThis field is deprecated.static interfaceA complex type that controls:.static interfaceA custom origin.static interfaceA complex type that describes the default cache behavior if you don't specify aCacheBehaviorelement or if request URLs don't match any of the values ofPathPatterninCacheBehaviorelements.static interfaceThe value that you assigned to the parameter.static interfaceA distribution configuration.static interfacestatic interfaceA CloudFront function that is associated with a cache behavior in a CloudFront distribution.static interfaceA complex type that controls the countries in which your content is distributed.static interfaceAmazon CloudFront supports gRPC, an open-source remote procedure call (RPC) framework built on HTTP/2.static interfaceA complex type that contains a Lambda@Edge function association.static interfaceA custom origin.static interfaceThe origin as an Amazon S3 bucket.static interfaceA complex type that specifies whether access logs are written for the distribution.static interfaceA complex type that containsHeaderNameandHeaderValueelements, if any, for this distribution.static interfaceA complex data type that includes information about the failover criteria for an origin group, including the status codes for which CloudFront will failover from the primary origin to the second origin.static interfaceAn origin in an origin group.static interfaceA complex data type for the origins included in an origin group.static interfaceAn origin group includes two origins (a primary origin and a secondary origin to failover to) and a failover criteria that you specify.static interfaceA complex data type for the origin groups specified for a distribution.static interfaceAn origin.static interfaceCloudFront Origin Shield.static interfaceA list of parameter values to add to the resource.static interfaceA complex type that identifies ways in which you want to restrict distribution of your content.static interfaceA complex type that contains information about the Amazon S3 origin.static interfaceA complex data type for the status codes that you specify that, when returned by a primary origin, trigger CloudFront to failover to a second origin.static interfaceExample:static interfacestatic interfaceA complex type that determines the distribution's SSL/TLS configuration for communicating with viewers.static interfaceAn Amazon CloudFront VPC origin configuration.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.interfaces.cloudfront.IDistributionRef
IDistributionRef.Jsii$Default, IDistributionRef.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnDistribution(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnDistribution(software.amazon.jsii.JsiiObjectRef objRef) CfnDistribution(software.constructs.Construct scope, String id, CfnDistributionProps props) Create a newAWS::CloudFront::Distribution. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringarnForDistribution(IDistributionRef resource) static IDistributionReffromDistributionId(software.constructs.Construct scope, String id, String distributionId) Creates a new IDistributionRef from a distributionId.The domain name of the resource, such asd111111abcdef8.cloudfront.net.rproxy.govskope.ca.The distribution's identifier.The distribution's configuration.A reference to a Distribution resource.getTags()Tag Manager which manages the tags for this resource.A complex type that contains zero or moreTagelements.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties(Map<String, Object> props) voidsetDistributionConfig(IResolvable value) The distribution's configuration.voidThe distribution's configuration.voidsetTagsRaw(List<CfnTag> value) A complex type that contains zero or moreTagelements.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getEnv, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods 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.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.interfaces.IEnvironmentAware
getEnvMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnDistribution
protected CfnDistribution(software.amazon.jsii.JsiiObjectRef objRef) -
CfnDistribution
protected CfnDistribution(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnDistribution
@Stability(Stable) public CfnDistribution(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnDistributionProps props) Create a newAWS::CloudFront::Distribution.- Parameters:
scope- Scope in which this resource is defined. This parameter is required.id- Construct identifier for this resource (unique in its scope). This parameter is required.props- Resource properties. This parameter is required.
-
-
Method Details
-
arnForDistribution
@Stability(Stable) @NotNull public static String arnForDistribution(@NotNull IDistributionRef resource) - Parameters:
resource- This parameter is required.
-
fromDistributionId
@Stability(Stable) @NotNull public static IDistributionRef fromDistributionId(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String distributionId) Creates a new IDistributionRef from a distributionId.- Parameters:
scope- This parameter is required.id- This parameter is required.distributionId- This parameter is required.
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrDomainName
The domain name of the resource, such asd111111abcdef8.cloudfront.net. -
getAttrId
The distribution's identifier.For example:
E1U5RQF7T870K0. -
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getDistributionRef
A reference to a Distribution resource.- Specified by:
getDistributionRefin interfaceIDistributionRef
-
getTags
Tag Manager which manages the tags for this resource. -
getDistributionConfig
The distribution's configuration.Returns union: either
IResolvableorCfnDistribution.DistributionConfigProperty -
setDistributionConfig
The distribution's configuration. -
setDistributionConfig
@Stability(Stable) public void setDistributionConfig(@NotNull CfnDistribution.DistributionConfigProperty value) The distribution's configuration. -
getTagsRaw
A complex type that contains zero or moreTagelements. -
setTagsRaw
A complex type that contains zero or moreTagelements.
-