@neweracode/cdk-static-site
TypeScript icon, indicating that this package has built-in type declarations

1.9.0 • Public • Published

NewEraCode Static Website Component

Description

An AWS CDK construct that creates static site infrastructure, which uses an S3 bucket for the content.

The site redirects from HTTP to HTTPS, using a CloudFront distribution, Route53 alias record, and ACM certificate.

The ACM certificate is expected to be created and validated outside of the CDK, with the certificate ARN stored in an SSM Parameter.

Usage

Install

npm i @neweracode/cdk-static-website

Import

NodeJS

const cds = require('@neweracode/cdk-static-site');
new cds.CdkStaticSite(....)

TypeScript / Babel

import { CdkStaticSite } from '@neweracode/cdk-static-site';

Example:

import { App, RemovalPolicy, Stack, StackProps } from '@aws-cdk/core';
import { CdkStaticSite } from './cdk-static-site';

export class ComponentStack extends Stack {
    public constructor(parent: App, name: string, props?: StackProps) {
        super(parent, name, props);

        new CdkStaticSite(this, 'StaticWebsite', {
            bucketConfiguration: {
                bucketName: "myBucket",
                removalPolicy: RemovalPolicy.RETAIN,
                websiteIndexDocument: "index.html",
                websiteErrorDocument: "error.html",
                source: "websiteFiles" // local directory with static files
            },
            aliasConfiguration: {
                domainName: "domain.com"
                siteDomain: "example.domain.com",
                acmCertRef: "arn:aws:acm:us-east-1:....."
            },
        });
    }
}

/@neweracode/cdk-static-site/

    Package Sidebar

    Install

    npm i @neweracode/cdk-static-site

    Weekly Downloads

    0

    Version

    1.9.0

    License

    MIT

    Unpacked Size

    15.8 kB

    Total Files

    6

    Last publish

    Collaborators

    • neweracode-jj