Norse Polytheistic Mythology

    TypeScript icon, indicating that this package has built-in type declarations

    2.12.0 • Public • Published

    AWS CDK S3 Cloudfront Construct

    This package provides a CDK construct that creates a Cloudfront distribution which serves content from S3 and is integrated with Route 53 and ACM. Specifically, it:

    • Creates a private S3 bucket
    • Creates a CloudFront distribution for that bucket
    • Optionally creates a Route53 record pointing to that bucket
    • Optionally creates a certificate for the distribution if a domain name is used (can use existing)
    • Optionally adds subsomain redirects, .e.g. redirects to the main
    • Optionally uploads content file to the S3 bucket and invalidates the distribution if it is already existing


    The minor version of the package is synchronized to the CDK version used.


    • An aws account and relevant profile configured

    Example usage

    new S3CloudFront(this, 'S3CloudFront', {
      domain: {
        domainName: '', // The domain name's TLD must be an existing hosted zone in Route53
        tld: '',
      subdomainRedirects: ['www'],
      bucketName: 'examplenonadigital',
      error404Document: '404.html',


    • You need to have the correct AWS_PROFILE environment variable set as the CDK_DEFAULT_ACCOUNT and CDK_DEFAULT_REGION are picked up from the AWS_PROFILE environment variable

    • As the bucket is private and does not use S3 hosting, you need to add an edge lambda to serve index documents. The aws-cdk-standard-cloudfront-lambdas package provides these.

    See example app for a complete example


    npm i @nona-creative/aws-cdk-s3-cloudfront

    DownloadsWeekly Downloads






    Unpacked Size

    87.7 kB

    Total Files


    Last publish


    • yesitsdave
    • syntaxza
    • rollyourowned
    • neilrussell6
    • ian-cawood