@ukautz/aws-cdk-static-website
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

AWS CDK: Static Website

An AWS CDK Level 3 construct that implements an opinionated static website in AWS using:

  • A public readable S3 bucket, that mirrors the contents of local directory of .html files and related assets
  • A CloudFront distribution, that caches the S3 delivery and enforces HTTPS
  • Route53 record(s) that route one or multiple public domains to S3
  • A certificate for the provided public domain(s) for HTTPS

Diagram

Usage

Install package:

$ npm install @ukautz/aws-cdk-static-website

Then in your stack:

import * as cdk from 'aws-cdk-lib';
import { aws_route53 as route53 } from 'aws-cdk-lib';
import { StaticWebsite } from '@ukautz/aws-cdk-static-website';
import { Construct } from 'constructs';

export class YourStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.Stack) {
    super(scope, id, props);

    // load (or create) a hosted zone, in which the record(s) will be created
    const hostedZone = route53.HostedZone.fromLookup(this, 'HostedZone', {
      domainName: 'your-domain.tld',
    });

    // create a static website, that uploads and serves contents from a local folder
    new StaticWebsite(this, 'StaticWebsite', {
      directory: '/path/to/where/your/contents/are',
      domain: 'blog.your-domain.tld',
      hostedZone,
    });
  }
}

Note: See the StaticWebsiteProps interface for all available properties.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @ukautz/aws-cdk-static-website

Weekly Downloads

1

Version

2.2.0

License

MIT

Unpacked Size

180 kB

Total Files

20

Last publish

Collaborators

  • ukautz