Created
August 8, 2019 19:28
-
-
Save jewelsjacobs/4e5cff3de439951624e1899ac5ffcfff to your computer and use it in GitHub Desktop.
Cloudfront Stack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { App, Stack, StackProps, RemovalPolicy } from '@aws-cdk/core'; | |
| import { StaticWebsite } from '@cloudcomponents/cdk-static-website'; | |
| /** | |
| * 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. | |
| */ | |
| export class ComponentStack extends Stack { | |
| constructor(parent: App, name: string, props?: StackProps) { | |
| super(parent, name, props); | |
| new StaticWebsite(this, 'StaticWebsite', { | |
| bucketConfiguration: { | |
| bucketName: process.env.S3_BUCKET, | |
| removalPolicy: RemovalPolicy.DESTROY, | |
| disableUpload: false, | |
| websiteIndexDocument: process.env.INDEX_PAGE, | |
| websiteErrorDocument: process.env.ERROR_PAGE, | |
| source: './html' | |
| }, | |
| aliasConfiguration: { | |
| domainName: process.env.DOMAIN as string, | |
| names: [`${process.env.SUBDOMAIN}.${process.env.DOMAIN}`, `${process.env.DOMAIN}`], | |
| acmCertRef: process.env.ACM_CERT_REF as string, | |
| }, | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment