UNPKG

@scloud/cdk-patterns

Version:

Serverless CDK patterns for common infrastructure needs

39 lines (38 loc) 2.24 kB
import { DnsValidatedCertificate } from 'aws-cdk-lib/aws-certificatemanager'; import { Distribution, DistributionProps, ErrorResponse } from 'aws-cdk-lib/aws-cloudfront'; import { IHostedZone } from 'aws-cdk-lib/aws-route53'; import { Bucket } from 'aws-cdk-lib/aws-s3'; import { Construct } from 'constructs'; /** * @param zone The DNS zone for this web app. By default the domain name is set to the zone name * The type IHostedZone enables lookup of the zone (IHostedZone) as well as a zone creatd in the stack (HostedZone) * @param domainName Optional: by default the zone name will be mapped to the Cloudfront distribution (e.g. 'example.com') but you can specify a different domain here (e.g. 'subdomain.example.com'). * @param defaultIndex Default: true. Maps a viewer request for '/' to a request for /index.html. * @param redirectWww Default: true. Redirects www requests to the bare domain name, e.g. www.example.com->example.com, www.sub.example.com->sub.example.com. * @param cnameAliases Optional: additional CNAMEs to add to the Cloudfront distribution. This allows you to use a domain name configured outside of AWS. * @param distributionProps Optional: If you want to add additional properties to the Cloudfront distribution, you can pass them here. * @param errorResponses Optional: If you want to add custom error responses to the Cloudfront distribution, you can pass them here. */ export interface WebFrontendProps { zone: IHostedZone; domainName?: string; defaultIndex?: boolean; redirectWww?: boolean; cnameAliases?: string[]; distributionProps?: Partial<DistributionProps>; errorResponses?: ErrorResponse[]; } /** * A Cloudfront distribution backed by an s3 bucket. * * The bucket and contents are treated as expendable on the basis they are assumed to be generated by a CI/CD process that can rebuild the content. * * NB us-east-1 is required for Cloudfront certificates: * https://docs.aws.amazon.com/cdk/api/v1/docs/aws-cloudfront-readme.html */ export declare class WebFrontend extends Construct { bucket: Bucket; distribution: Distribution; certificate: DnsValidatedCertificate; constructor(scope: Construct, id: string, props: WebFrontendProps); }