@nona-creative/aws-cdk-s3-cloudfront
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.13400 • 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. www.nona.digital redirects to the main nona.digital
    • Optionally uploads content file to the S3 bucket and invalidates the distribution if it is already existing

    Versioning

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

    Prerequisites

    • An aws account and relevant profile configured

    Example usage

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

    Notes:

    • 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

    Install

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

    DownloadsWeekly Downloads

    217

    Version

    1.1.13400

    License

    MIT

    Unpacked Size

    88.4 kB

    Total Files

    30

    Last publish

    Collaborators

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