Interface IDistributionProps
Properties for a Distribution.
Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface IDistributionProps
Syntax (vb)
Public Interface IDistributionProps
Remarks
ExampleMetadata: infused
Examples
// Creates a distribution from an Application Load Balancer
Vpc vpc;
// Create an application load balancer in a VPC. 'internetFacing' can be 'false'.
var alb = new ApplicationLoadBalancer(this, "ALB", new ApplicationLoadBalancerProps {
Vpc = vpc,
InternetFacing = false,
VpcSubnets = new SubnetSelection { SubnetType = SubnetType.PRIVATE_ISOLATED }
});
new Distribution(this, "myDist", new DistributionProps {
DefaultBehavior = new BehaviorOptions { Origin = VpcOrigin.WithApplicationLoadBalancer(alb) }
});
Synopsis
Properties
AdditionalBehaviors | Additional behaviors for the distribution, mapped by the pathPattern that specifies which requests to apply the behavior to. |
Certificate | A certificate to associate with the distribution. |
Comment | Any comments you want to include about the distribution. |
DefaultBehavior | The default behavior for the distribution. |
DefaultRootObject | The object that you want CloudFront to request from your origin (for example, index.html) when a viewer requests the root URL for your distribution. If no default object is set, the request goes to the origin's root (e.g., example.com/). |
DomainNames | Alternative domain names for this distribution. |
EnableIpv6 | Whether CloudFront will respond to IPv6 DNS requests with an IPv6 address. |
EnableLogging | Enable access logging for the distribution. |
Enabled | Enable or disable the distribution. |
ErrorResponses | How CloudFront should handle requests that are not successful (e.g., PageNotFound). |
GeoRestriction | Controls the countries in which your content is distributed. |
HttpVersion | Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. |
LogBucket | The Amazon S3 bucket to store the access logs in. |
LogFilePrefix | An optional string that you want CloudFront to prefix to the access log filenames for this distribution. |
LogIncludesCookies | Specifies whether you want CloudFront to include cookies in access logs. |
MinimumProtocolVersion | The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections. |
PriceClass | The price class that corresponds with the maximum price that you want to pay for CloudFront service. |
PublishAdditionalMetrics | Whether to enable additional CloudWatch metrics. |
SslSupportMethod | The SSL method CloudFront will use for your distribution. |
WebAclId | Unique identifier that specifies the AWS WAF web ACL to associate with this CloudFront distribution. |
Properties
AdditionalBehaviors
Additional behaviors for the distribution, mapped by the pathPattern that specifies which requests to apply the behavior to.
IDictionary<string, IBehaviorOptions>? AdditionalBehaviors { get; }
Property Value
IDictionary<string, IBehaviorOptions>
Remarks
Default: - no additional behaviors are added.
Certificate
A certificate to associate with the distribution.
ICertificate? Certificate { get; }
Property Value
Remarks
The certificate must be located in N. Virginia (us-east-1).
Default: - the CloudFront wildcard certificate (*.cloudfront.net) will be used.
Comment
Any comments you want to include about the distribution.
string? Comment { get; }
Property Value
Remarks
Default: - no comment
DefaultBehavior
The default behavior for the distribution.
IBehaviorOptions DefaultBehavior { get; }
Property Value
Remarks
ExampleMetadata: infused
DefaultRootObject
The object that you want CloudFront to request from your origin (for example, index.html) when a viewer requests the root URL for your distribution. If no default object is set, the request goes to the origin's root (e.g., example.com/).
string? DefaultRootObject { get; }
Property Value
Remarks
Default: - no default root object
DomainNames
Alternative domain names for this distribution.
string[]? DomainNames { get; }
Property Value
string[]
Remarks
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.
Default: - The distribution will only support the default generated name (e.g., d111111abcdef8.cloudfront.net)
EnableIpv6
Whether CloudFront will respond to IPv6 DNS requests with an IPv6 address.
bool? EnableIpv6 { get; }
Property Value
bool?
Remarks
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.
Default: true
EnableLogging
Enable access logging for the distribution.
bool? EnableLogging { get; }
Property Value
bool?
Remarks
Default: - false, unless logBucket
is specified.
Enabled
Enable or disable the distribution.
bool? Enabled { get; }
Property Value
bool?
Remarks
Default: true
ErrorResponses
How CloudFront should handle requests that are not successful (e.g., PageNotFound).
IErrorResponse[]? ErrorResponses { get; }
Property Value
Remarks
Default: - No custom error responses.
GeoRestriction
Controls the countries in which your content is distributed.
GeoRestriction? GeoRestriction { get; }
Property Value
Remarks
Default: - No geographic restrictions
HttpVersion
Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront.
HttpVersion? HttpVersion { get; }
Property Value
Remarks
For viewers and CloudFront to use HTTP/2, viewers must support TLS 1.2 or later, and must support server name identification (SNI).
Default: HttpVersion.HTTP2
LogBucket
The Amazon S3 bucket to store the access logs in.
IBucket? LogBucket { get; }
Property Value
Remarks
Make sure to set objectOwnership
to s3.ObjectOwnership.OBJECT_WRITER
in your custom bucket.
Default: - A bucket is created if enableLogging
is true
LogFilePrefix
An optional string that you want CloudFront to prefix to the access log filenames for this distribution.
string? LogFilePrefix { get; }
Property Value
Remarks
Default: - no prefix
LogIncludesCookies
Specifies whether you want CloudFront to include cookies in access logs.
bool? LogIncludesCookies { get; }
Property Value
bool?
Remarks
Default: false
MinimumProtocolVersion
The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections.
SecurityPolicyProtocol? MinimumProtocolVersion { get; }
Property Value
Remarks
CloudFront serves your objects only to browsers or devices that support at least the SSL version that you specify.
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.
PriceClass
The price class that corresponds with the maximum price that you want to pay for CloudFront service.
PriceClass? PriceClass { get; }
Property Value
Remarks
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.
Default: PriceClass.PRICE_CLASS_ALL
PublishAdditionalMetrics
Whether to enable additional CloudWatch metrics.
bool? PublishAdditionalMetrics { get; }
Property Value
bool?
Remarks
SslSupportMethod
The SSL method CloudFront will use for your distribution.
SSLMethod? SslSupportMethod { get; }
Property Value
Remarks
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/
Default: SSLMethod.SNI
WebAclId
Unique identifier that specifies the AWS WAF web ACL to associate with this CloudFront distribution.
string? WebAclId { get; }
Property Value
Remarks
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
.
Default: - No AWS Web Application Firewall web access control list (web ACL).