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
// Adding an existing Lambda@Edge function created in a different stack
// to a CloudFront distribution.
Bucket s3Bucket;
var functionVersion = Version.FromVersionArn(this, "Version", "arn:aws:lambda:us-east-1:123456789012:function:functionName:1");
new Distribution(this, "distro", new DistributionProps {
DefaultBehavior = new BehaviorOptions {
Origin = new S3Origin(s3Bucket),
EdgeLambdas = new [] { new EdgeLambda {
FunctionVersion = functionVersion,
EventType = LambdaEdgeEventType.VIEWER_REQUEST
} }
}
});
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. |
Enabled | Enable or disable the distribution. |
EnableIpv6 | Whether CloudFront will respond to IPv6 DNS requests with an IPv6 address. |
EnableLogging | Enable access logging for 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.
virtual IDictionary<string, IBehaviorOptions> AdditionalBehaviors { get; }
Property Value
System.Collections.Generic.IDictionary<System.String, IBehaviorOptions>
Remarks
Default: - no additional behaviors are added.
Certificate
A certificate to associate with the distribution.
virtual 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.
virtual string Comment { get; }
Property Value
System.String
Remarks
Default: - no comment
DefaultBehavior
The default behavior for the distribution.
IBehaviorOptions DefaultBehavior { get; }
Property Value
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/).
virtual string DefaultRootObject { get; }
Property Value
System.String
Remarks
Default: - no default root object
DomainNames
Alternative domain names for this distribution.
virtual string[] DomainNames { get; }
Property Value
System.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)
Enabled
Enable or disable the distribution.
virtual Nullable<bool> Enabled { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: true
EnableIpv6
Whether CloudFront will respond to IPv6 DNS requests with an IPv6 address.
virtual Nullable<bool> EnableIpv6 { get; }
Property Value
System.Nullable<System.Boolean>
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.
virtual Nullable<bool> EnableLogging { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: - false, unless logBucket
is specified.
ErrorResponses
How CloudFront should handle requests that are not successful (e.g., PageNotFound).
virtual IErrorResponse[] ErrorResponses { get; }
Property Value
Remarks
Default: - No custom error responses.
GeoRestriction
Controls the countries in which your content is distributed.
virtual 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.
virtual Nullable<HttpVersion> HttpVersion { get; }
Property Value
System.Nullable<HttpVersion>
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.
virtual 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.
virtual string LogFilePrefix { get; }
Property Value
System.String
Remarks
Default: - no prefix
LogIncludesCookies
Specifies whether you want CloudFront to include cookies in access logs.
virtual Nullable<bool> LogIncludesCookies { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
Default: false
MinimumProtocolVersion
The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections.
virtual Nullable<SecurityPolicyProtocol> MinimumProtocolVersion { get; }
Property Value
System.Nullable<SecurityPolicyProtocol>
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.
virtual Nullable<PriceClass> PriceClass { get; }
Property Value
System.Nullable<PriceClass>
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.
virtual Nullable<bool> PublishAdditionalMetrics { get; }
Property Value
System.Nullable<System.Boolean>
Remarks
SslSupportMethod
The SSL method CloudFront will use for your distribution.
virtual Nullable<SSLMethod> SslSupportMethod { get; }
Property Value
System.Nullable<SSLMethod>
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.
virtual string WebAclId { get; }
Property Value
System.String
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).