@aws-cdk/cloudfront

AWS CloudFront Construct Library

A CloudFront construct - for setting up the AWS CDN with ease!

Example usage:

const sourceBucket = new Bucket(this, 'Bucket');

const distribution = new CloudFrontDistribution(this, 'MyDistribution', {
    originConfigs: [
        {
            s3OriginSource: {
                s3BucketSource: sourceBucket
            },
            behaviors : [ {isDefaultBehavior}]
        }
    ]
 });

Reference

AliasConfiguration (interface)

class _aws-cdk_cloudfront.AliasConfiguration

CloudFront can use a custom domain that you provide instead of a “cloudfront.net” domain. To use this feature - you must provide the list of additional domains, and the ACM Certificate that CloudFront should use for these additional domains. Note - CloudFront only accepts one additional certificate - therefore the certificate must use have SANs (Subject Alternative Names) for all domains listed. sslMethod is optional - we default to SNI if not specified. See the notes on SSLMethod if you wish to use other SSL termination types.

names
Type:string (readonly)
acmCertRef
Type:CertificateArn (readonly)
sslMethod
Type:string or None (readonly)

Behavior (interface)

class _aws-cdk_cloudfront.Behavior

A CloudFront behavior wrapper.

compress

If CloudFront should automatically compress some content types.

Type:boolean or None
isDefaultBehavior

If this behavior is the default behavior for the distribution. You must specify exactly one default distribution per CloudFront distribution. The default behavior is allowed to omit the “path” property.

Type:boolean or None
trustedSigners

Trusted signers is how CloudFront allows you to serve private content. The signers are the account IDs that are allowed to sign cookies/presigned URLs for this distribution. If you pass a non empty value, all requests for this behavior must be signed (no public access will be allowed)

Type:string or None
defaultTtlSeconds

The default amount of time CloudFront will cache an object. This value applies only when your custom origin does not add HTTP headers, such as Cache-Control max-age, Cache-Control s-maxage, and Expires to objects.

Type:number or None
allowedMethods

The method this CloudFront distribution responds do.

Type:string or None
pathPattern

The path this behavior responds to. Required for all non-default behaviors. (The default behavior implicitly has “*” as the path pattern. )

Type:string or None
cachedMethods

Which methods are cached by CloudFront by default.

Type:string or None
forwardedValues

The values CloudFront will forward to the origin when making a request.

Type:ForwardedValuesProperty or None
minTtlSeconds

The minimum amount of time that you want objects to stay in the cache before CloudFront queries your origin.

Type:number or None
maxTtlSeconds

The max amount of time you want objects to stay in the cache before CloudFront queries your origin.

Type:number or None

CloudFrontAllowedCachedMethods (enum)

class _aws-cdk_cloudfront.CloudFrontAllowedCachedMethods
GET_HEAD
GET_HEAD_OPTIONS

CloudFrontAllowedMethods (enum)

class _aws-cdk_cloudfront.CloudFrontAllowedMethods
GET_HEAD
GET_HEAD_OPTIONS
ALL

CloudFrontWebDistribution

class _aws-cdk_cloudfront.CloudFrontWebDistribution(parent, name, props)

Amazon CloudFront is a global content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to your viewers with low latency and high transfer speeds. CloudFront fronts user provided content and caches it at edge locations across the world. Here’s how you can use this construct: `ts  * import { CloudFront } from '@aws-cdk/cloudfront'  *  * const sourceBucket = new Bucket(this, 'Bucket');  *  * const distribution = new CloudFrontDistribution(this, 'MyDistribution', {  *  originConfigs: [  *      {  *          s3OriginSource: {  *            s3BucketSource: sourceBucket  *          },  *          behaviors : [ {isDefaultBehavior}]  *      }  *  ]  * });  * ` This will create a CloudFront distribution that uses your S3Bucket as it’s origin. You can customize the distribution using additional properties from the CloudFrontWebDistributionProps interface.

Extends:

Construct

Parameters:
  • parent (Construct) –
  • name (string) –
  • props (CloudFrontWebDistributionProps) –
aliasHostedZoneId

The hosted zone Id if using an alias record in Route53. This value never changes.

Type:string (readonly)
loggingBucket

The logging bucket for this CloudFront distribution. If logging is not enabled for this distribution - this property will be undefined.

Type:BucketRef or None (readonly)
domainName

The domain name created by CloudFront for this distribution. If you are using aliases for your distribution, this is the domainName your DNS records should point to. (In Route53, you could create an ALIAS record to this value, for example. )

Type:DistributionDomainName (readonly)

CloudFrontWebDistributionProps (interface)

class _aws-cdk_cloudfront.CloudFrontWebDistributionProps
aliasConfiguration

AliasConfiguration is used to configured CloudFront to respond to requests on custom domain names.

Type:AliasConfiguration or None
comment

A comment for this distribution in the cloud front console.

Type:string or None
defaultRootObject

The default object to serve.

Type:string or None
enableIpV6

If your distribution should have IPv6 enabled.

Type:boolean or None
httpVersion

The max supported HTTP Versions.

Type:string or None
priceClass

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

Type:string or None
viewerProtocolPolicy

The default viewer policy for incoming clients.

Type:string or None
originConfigs

The origin configurations for this distribution. Behaviors are a part of the origin.

Type:SourceConfiguration
loggingConfig

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.

Type:LoggingConfiguration or None
errorConfigurations

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

Type:CustomErrorResponseProperty or None

CustomOriginConfig (interface)

class _aws-cdk_cloudfront.CustomOriginConfig

A custom origin configuration

domainName

The domain name of the custom origin. Should not include the path - that should be in the parent SourceConfiguration

Type:string (readonly)
httpPort

The origin HTTP port

Type:number or None (readonly)
httpsPort

The origin HTTPS port

Type:number or None (readonly)
originKeepaliveTimeoutSeconds

The keep alive timeout when making calls in seconds.

Type:number or None (readonly)
originProtocolPolicy

The protocol (http or https) policy to use when interacting with the origin.

Type:string or None (readonly)
originReadTimeoutSeconds

The read timeout when calling the origin in seconds

Type:number or None (readonly)
allowedOriginSSLVersions

The SSL versions to use when interacting with the origin.

Type:OriginSslPolicy or None (readonly)

ErrorConfiguration (interface)

class _aws-cdk_cloudfront.ErrorConfiguration
originErrorCode

The error code matched from the origin

Type:number
respondWithErrorCode

The error code that is sent to the caller.

Type:number
respondWithPage

The path to service instead

Type:string
cacheTtl

How long before this error is retried.

Type:number or None

HttpVersion (enum)

class _aws-cdk_cloudfront.HttpVersion
HTTP1_1
HTTP2

LoggingConfiguration (interface)

class _aws-cdk_cloudfront.LoggingConfiguration

CloudFront supports logging of incoming requests and can log details to a given S3 Bucket. If you wish to configure logging you can configure details about it.

bucket
Type:BucketRef or None (readonly)
includeCookies
Type:boolean or None (readonly)
prefix
Type:string or None (readonly)

OriginProtocolPolicy (enum)

class _aws-cdk_cloudfront.OriginProtocolPolicy
HttpOnly
MatchViewer
HttpsOnly

OriginSslPolicy (enum)

class _aws-cdk_cloudfront.OriginSslPolicy
SSLv3
TLSv1
TLSv1_1
TLSv1_2

PriceClass (enum)

class _aws-cdk_cloudfront.PriceClass
PriceClass100
PriceClass200
PriceClassAll

S3OriginConfig (interface)

class _aws-cdk_cloudfront.S3OriginConfig
s3BucketSource

The source bucket to serve content from

Type:Bucket (readonly)
originAccessIdentity

The optional origin identity cloudfront will use when calling your s3 bucket.

Type:CloudFrontOriginAccessIdentityResource or None (readonly)

SSLMethod (enum)

class _aws-cdk_cloudfront.SSLMethod
SNI
VIP

SourceConfiguration (interface)

class _aws-cdk_cloudfront.SourceConfiguration

A source configuration is a wrapper for CloudFront origins and behaviors. An origin is what CloudFront will “be in front of” - that is, CloudFront will pull it’s assets from an origin. If you’re using s3 as a source - pass the s3Origin property, otherwise, pass the customOriginSource property. One or the other must be passed, and it is invalid to pass both in the same SourceConfiguration.

s3OriginSource

An s3 origin source - if you’re using s3 for your assets

Type:S3OriginConfig or None (readonly)
customOriginSource

A custom origin source - for all non-s3 sources.

Type:CustomOriginConfig or None (readonly)
behaviors

The behaviors associated with this source. At least one (default) behavior must be included.

Type:Behavior (readonly)
originPath

The relative path to the origin root to use for sources.

Type:string or None (readonly)
originHeaders

Any additional headers to pass to the origin

Type:string or None (readonly)

ViewerProtocolPolicy (enum)

class _aws-cdk_cloudfront.ViewerProtocolPolicy
HTTPSOnly
RedirectToHTTPS
AllowAll