1.198.1-2 • Published 1 year ago

cdk-static-web v1.198.1-2

Weekly downloads
151
License
MIT
Repository
github
Last release
1 year ago

cdk-static-web

Simple, injectable construct to host a static website. The AWS examples and other packages seemed to use deprecated stuff so I figured I'd roll my own.

Features

  • Origin Access Identities
  • Optional index path rewriting and redirection (/potato will rewrite to /potato/index.html and also redirect to /potato/).

Example

import * as acm from "@aws-cdk/aws-certificatemanager";
import { PriceClass } from "@aws-cdk/aws-cloudfront";
import * as route53 from "@aws-cdk/aws-route53";
import * as cdk from "@aws-cdk/core";
import { StaticWeb } from "cdk-static-web";

interface Props extends cdk.StackProps {
  domainName: string;
}

export class ExampleWebStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props: Props) {
    super(scope, id, props);
    const { domainName } = props;

    const zone = route53.PublicHostedZone.fromLookup(this, "ExampleZone", {
      domainName,
    });

    const certificate = new acm.DnsValidatedCertificate(this, "ExampleWebCert", {
      domainName,
      hostedZone: zone,
      region: "us-east-1",
    });

    new StaticWeb(this, "Example", {
      zone,
      certificate,
      isSPA: true, // This will make error documents 200 to index.html
      staticPath: "./public",
      distributionProps: {
        priceClass: PriceClass.PRICE_CLASS_100,
      },
    });
  }
}

API Reference

See API.md.

License

MIT

1.198.1-2

1 year ago

1.198.1

1 year ago

1.182.0

1 year ago

1.159.0

2 years ago

1.156.1

2 years ago

1.150.0

2 years ago

1.152.0

2 years ago

1.132.0

2 years ago

1.130.0

2 years ago

1.130.0-qs1

2 years ago

1.130.0-qs2

2 years ago

1.131.0

2 years ago

1.128.0

3 years ago

1.129.0

3 years ago

1.127.0

3 years ago

1.124.0

3 years ago

1.122.0

3 years ago

1.120.0

3 years ago

1.121.0

3 years ago

1.119.0

3 years ago

1.118.0

3 years ago

1.117.0

3 years ago

1.116.0

3 years ago

1.115.0

3 years ago

1.114.0-edge2

3 years ago

1.114.0-edge1

3 years ago

1.114.0

3 years ago

1.113.0-2

3 years ago

1.113.0-3

3 years ago

1.113.0

3 years ago

1.111.0

3 years ago

1.110.1

3 years ago

1.110.0

3 years ago

1.110.0-3

3 years ago

1.110.0-2

3 years ago

1.110.0-1

3 years ago

1.109.0-9

3 years ago

1.109.0-8

3 years ago

1.109.0-7

3 years ago

1.109.0-3

3 years ago

1.109.0-2

3 years ago

1.109.0

3 years ago

1.109.0-5

3 years ago

1.109.0-4

3 years ago

1.108.0

3 years ago

1.102.0

3 years ago

1.100.0

3 years ago

1.97.0

3 years ago

1.95.2

3 years ago

1.94.1

3 years ago

1.93.0

3 years ago

1.92.0

3 years ago

1.92.0-2

3 years ago

1.91.0-2

3 years ago

1.91.0

3 years ago

1.90.1

3 years ago

1.90.0

3 years ago

1.89.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.5.1

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago