DistributionProps Struct
Properties for a Distribution.
Example
// Creates a distribution from a Network Load Balancer
declare const vpc: ec2.Vpc;
// Create a network load balancer in a VPC. 'internetFacing' can be 'false'.
const nlb = new elbv2.NetworkLoadBalancer(this, 'NLB', {
vpc,
internetFacing: false,
vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_ISOLATED },
securityGroups: [new ec2.SecurityGroup(this, 'NLB-SG', { vpc })],
});
new cloudfront.Distribution(this, 'myDist', {
defaultBehavior: { origin: origins.VpcOrigin.withNetworkLoadBalancer(nlb) },
});
Properties
additionalBehaviorsoptional{ [key: string]: BehaviorOptions }additional_behaviorsoptionaltyping.Mapping[str, BehaviorOptions]additionalBehaviorsoptionalMap<String, BehaviorOptions>AdditionalBehaviorsoptionalIDictionary<string, BehaviorOptions>AdditionalBehaviorsoptional*map[string]BehaviorOptions#Default: no additional behaviors are added.
certificateoptionalICertificateRefcertificateoptionalICertificateRefcertificateoptionalICertificateRefCertificateoptionalICertificateRefCertificateoptionalICertificateRef#Default: the CloudFront wildcard certificate (*.cloudfront.net) will be used.
The certificate must be located in N. Virginia (us-east-1).
commentoptionalstringcommentoptionalstrcommentoptionalStringCommentoptionalstringCommentoptional*string#Default: no comment
defaultBehaviorBehaviorOptionsdefault_behaviorBehaviorOptionsdefaultBehaviorBehaviorOptionsDefaultBehaviorBehaviorOptionsDefaultBehaviorBehaviorOptionsrequired#defaultRootObjectoptionalstringdefault_root_objectoptionalstrdefaultRootObjectoptionalStringDefaultRootObjectoptionalstringDefaultRootObjectoptional*string#Default: no default root object
domainNamesoptionalstring[]domain_namesoptionaltyping.List[str]domainNamesoptionalList<String>DomainNamesoptionalstring[]DomainNamesoptional*[]*string#Default: The distribution will only support the default generated name (e.g., d111111abcdef8.cloudfront.net)
notes
If you want to use your own domain name, such as www.example.com, instead of the cloudfront.net domain name, you can add an alternate domain name to your distribution. If you attach a certificate to the distribution, you should add (at least one of) the domain names of the certificate to this list.
When you want to move a domain name between distributions, you can associate a certificate without specifying any domain names. For more information, see the Moving an alternate domain name to a different distribution section in the README.
enabledoptionalbooleanenabledoptionalboolenabledoptionalBooleanEnabledoptionalboolEnabledoptional*bool= true#enableIpv6optionalbooleanenable_ipv6optionalboolenableIpv6optionalBooleanEnableIpv6optionalboolEnableIpv6optional*bool= true#If you specify false, CloudFront responds to IPv6 DNS requests with the DNS response code NOERROR and with no IP addresses. This allows viewers to submit a second request, for an IPv4 address for your distribution.
enableLoggingoptionalbooleanenable_loggingoptionalboolenableLoggingoptionalBooleanEnableLoggingoptionalboolEnableLoggingoptional*bool#Default: false, unless logBucket is specified.
errorResponsesoptionalErrorResponse[]error_responsesoptionaltyping.List[ErrorResponse]errorResponsesoptionalList<ErrorResponse>ErrorResponsesoptionalErrorResponse[]ErrorResponsesoptional*[]ErrorResponse#Default: No custom error responses.
geoRestrictionoptionalGeoRestrictiongeo_restrictionoptionalGeoRestrictiongeoRestrictionoptionalGeoRestrictionGeoRestrictionoptionalGeoRestrictionGeoRestrictionoptionalGeoRestriction#Default: No geographic restrictions
httpVersionoptionalHttpVersionhttp_versionoptionalHttpVersionhttpVersionoptionalHttpVersionHttpVersionoptionalHttpVersionHttpVersionoptionalHttpVersion= HttpVersion.HTTP2#For viewers and CloudFront to use HTTP/2, viewers must support TLS 1.2 or later, and must support Server Name Indication (SNI). For viewers and CloudFront to use HTTP/3, viewers must support TLS 1.3 and Server Name Indication (SNI).
logBucketoptionalIBucketlog_bucketoptionalIBucketlogBucketoptionalIBucketLogBucketoptionalIBucketLogBucketoptionalIBucket#Default: A bucket is created if enableLogging is true
Make sure to set objectOwnership to s3.ObjectOwnership.OBJECT_WRITER in your custom bucket.
logFilePrefixoptionalstringlog_file_prefixoptionalstrlogFilePrefixoptionalStringLogFilePrefixoptionalstringLogFilePrefixoptional*string#Default: no prefix
logIncludesCookiesoptionalbooleanlog_includes_cookiesoptionalboollogIncludesCookiesoptionalBooleanLogIncludesCookiesoptionalboolLogIncludesCookiesoptional*bool= false#minimumProtocolVersionoptionalSecurityPolicyProtocolminimum_protocol_versionoptionalSecurityPolicyProtocolminimumProtocolVersionoptionalSecurityPolicyProtocolMinimumProtocolVersionoptionalSecurityPolicyProtocolMinimumProtocolVersionoptionalSecurityPolicyProtocol#Default: SecurityPolicyProtocol.TLS_V1_2_2021 if the '@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021' feature flag is set; otherwise, SecurityPolicyProtocol.TLS_V1_2_2019.
CloudFront serves your objects only to browsers or devices that support at least the SSL version that you specify.
priceClassoptionalPriceClassprice_classoptionalPriceClasspriceClassoptionalPriceClassPriceClassoptionalPriceClassPriceClassoptionalPriceClass= PriceClass.PRICE_CLASS_ALL#notes
If you specify PriceClass_All, CloudFront responds to requests for your objects from all CloudFront edge locations. If you specify a price class other than PriceClass_All, CloudFront serves your objects from the CloudFront edge location that has the lowest latency among the edge locations in your price class.
publishAdditionalMetricsoptionalbooleanpublish_additional_metricsoptionalboolpublishAdditionalMetricsoptionalBooleanPublishAdditionalMetricsoptionalboolPublishAdditionalMetricsoptional*bool= false#sslSupportMethodoptionalSSLMethodssl_support_methodoptionalSSLMethodsslSupportMethodoptionalSSLMethodSslSupportMethodoptionalSSLMethodSslSupportMethodoptionalSSLMethod= SSLMethod.SNI#notes
Server Name Indication (SNI) - is an extension to the TLS computer networking protocol by which a client indicates which hostname it is attempting to connect to at the start of the handshaking process. This allows a server to present multiple certificates on the same IP address and TCP port number and hence allows multiple secure (HTTPS) websites (or any other service over TLS) to be served by the same IP address without requiring all those sites to use the same certificate.
CloudFront can use SNI to host multiple distributions on the same IP - which a large majority of clients will support.
If your clients cannot support SNI however - CloudFront can use dedicated IPs for your distribution - but there is a prorated monthly charge for using this feature. By default, we use SNI - but you can optionally enable dedicated IPs (VIP).
See the CloudFront SSL for more details about pricing : https://aws.amazon.com/cloudfront/custom-ssl-domains/
webAclIdoptionalstringweb_acl_idoptionalstrwebAclIdoptionalStringWebAclIdoptionalstringWebAclIdoptional*string#Default: No AWS Web Application Firewall web access control list (web ACL).
notes
To specify a web ACL created using the latest version of AWS WAF, use the ACL ARN, for example arn:aws:wafv2:us-east-1:123456789012:global/webacl/ExampleWebACL/473e64fd-f30b-4765-81a0-62ad96dd167a. To specify a web ACL created using AWS WAF Classic, use the ACL ID, for example 473e64fd-f30b-4765-81a0-62ad96dd167a.