aws-cdk-lib.aws_cloudfront.CloudFrontWebDistributionProps

interface CloudFrontWebDistributionProps

LanguageType name
.NETAmazon.CDK.AWS.CloudFront.CloudFrontWebDistributionProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscloudfront#CloudFrontWebDistributionProps
Javasoftware.amazon.awscdk.services.cloudfront.CloudFrontWebDistributionProps
Pythonaws_cdk.aws_cloudfront.CloudFrontWebDistributionProps
TypeScript (source)aws-cdk-lib » aws_cloudfront » CloudFrontWebDistributionProps

Example

declare const sourceBucket: s3.Bucket;
const viewerCertificate = cloudfront.ViewerCertificate.fromIamCertificate('MYIAMROLEIDENTIFIER', {
  aliases: ['MYALIAS'],
});

new cloudfront.CloudFrontWebDistribution(this, 'MyCfWebDistribution', {
  originConfigs: [
    {
      s3OriginSource: {
        s3BucketSource: sourceBucket,
      },
      behaviors : [ {isDefaultBehavior: true} ],
    },
  ],
  viewerCertificate: viewerCertificate,
});

Properties

NameTypeDescription
originConfigsSourceConfiguration[]The origin configurations for this distribution.
comment?stringA comment for this distribution in the CloudFront console.
defaultRootObject?stringThe default object to serve.
enableIpV6?booleanIf your distribution should have IPv6 enabled.
enabled?booleanEnable or disable the distribution.
errorConfigurations?CustomErrorResponseProperty[]How CloudFront should handle requests that are not successful (eg PageNotFound).
geoRestriction?GeoRestrictionControls the countries in which your content is distributed.
httpVersion?HttpVersionThe max supported HTTP Versions.
loggingConfig?LoggingConfigurationOptional - if we should enable logging.
priceClass?PriceClassThe price class for the distribution (this impacts how many locations CloudFront uses for your distribution, and billing).
viewerCertificate?ViewerCertificateSpecifies whether you want viewers to use HTTP or HTTPS to request your objects, whether you're using an alternate domain name with HTTPS, and if so, if you're using AWS Certificate Manager (ACM) or a third-party certificate authority.
viewerProtocolPolicy?ViewerProtocolPolicyThe default viewer policy for incoming clients.
webACLId?stringUnique identifier that specifies the AWS WAF web ACL to associate with this CloudFront distribution.

originConfigs

Type: SourceConfiguration[]

The origin configurations for this distribution.

Behaviors are a part of the origin.


comment?

Type: string (optional, default: No comment is added to distribution.)

A comment for this distribution in the CloudFront console.


defaultRootObject?

Type: string (optional, default: "index.html" is served.)

The default object to serve.


enableIpV6?

Type: boolean (optional, default: true)

If your distribution should have IPv6 enabled.


enabled?

Type: boolean (optional, default: true)

Enable or disable the distribution.


errorConfigurations?

Type: CustomErrorResponseProperty[] (optional, default: No custom error configuration.)

How CloudFront should handle requests that are not successful (eg PageNotFound).

By default, CloudFront does not replace HTTP status codes in the 4xx and 5xx range with custom error messages. CloudFront does not cache HTTP status codes.


geoRestriction?

Type: GeoRestriction (optional, default: No geo restriction)

Controls the countries in which your content is distributed.


httpVersion?

Type: HttpVersion (optional, default: HttpVersion.HTTP2)

The max supported HTTP Versions.


loggingConfig?

Type: LoggingConfiguration (optional, default: no logging is enabled by default.)

Optional - if we should enable logging.

You can pass an empty object ({}) to have us auto create a bucket for logging. Omission of this property indicates no logging is to be enabled.


priceClass?

Type: PriceClass (optional, default: PriceClass.PRICE_CLASS_100 the cheapest option for CloudFront is picked by default.)

The price class for the distribution (this impacts how many locations CloudFront uses for your distribution, and billing).


viewerCertificate?

Type: ViewerCertificate (optional, default: ViewerCertificate.fromCloudFrontDefaultCertificate())

Specifies whether you want viewers to use HTTP or HTTPS to request your objects, whether you're using an alternate domain name with HTTPS, and if so, if you're using AWS Certificate Manager (ACM) or a third-party certificate authority.

See also: https://aws.amazon.com/premiumsupport/knowledge-center/custom-ssl-certificate-cloudfront/


viewerProtocolPolicy?

Type: ViewerProtocolPolicy (optional, default: RedirectToHTTPs)

The default viewer policy for incoming clients.


webACLId?

Type: string (optional, default: No AWS Web Application Firewall web access control list (web ACL).)

Unique identifier that specifies the AWS WAF web ACL to associate with this CloudFront distribution.

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.

See also: https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateDistribution.html#API_CreateDistribution_RequestParameters.