import { RemovalPolicy } from 'aws-cdk-lib'; import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager'; import { Distribution, ErrorResponse, PriceClass } from 'aws-cdk-lib/aws-cloudfront'; import { IHostedZone } from 'aws-cdk-lib/aws-route53'; import { Bucket } from 'aws-cdk-lib/aws-s3'; import { Asset } from 'aws-cdk-lib/aws-s3-assets'; import { BucketDeployment } from 'aws-cdk-lib/aws-s3-deployment'; import { Construct } from 'constructs'; /** * Default CloudFront error responses for Single Page Applications */ export declare const DEFAULT_SPA_ERROR_RESPONSES: ErrorResponse[]; /** * Custom domain configuration for the frontend */ export interface CustomDomainConfig { /** Domain name for the frontend (e.g., 'app.example.com') */ readonly domainName: string; /** SSL certificate for the domain (required when domainName is provided) */ readonly certificate: ICertificate; /** Optional hosted zone for automatic DNS record creation */ readonly hostedZone?: IHostedZone; } /** * Additional CloudFront distribution properties */ export interface AdditionalDistributionProps { /** Optional comment for the distribution */ readonly comment?: string; /** Optional enabled flag for the distribution */ readonly enabled?: boolean; /** Optional price class for the distribution */ readonly priceClass?: PriceClass; /** Optional web ACL ID for the distribution */ readonly webAclId?: string; } /** * Properties for the Frontend construct */ export interface FrontendProps { /** Base directory of the frontend source code */ readonly sourceDirectory: string; /** Directory where build artifacts are located after build command completes (defaults to '{sourceDirectory}/build') */ readonly buildOutputDirectory?: string; /** Optional build command (defaults to 'npm run build') */ readonly buildCommand?: string; /** Optional custom domain configuration */ readonly customDomain?: CustomDomainConfig; /** Optional CloudFront error responses (defaults to SPA-friendly responses) */ readonly errorResponses?: ErrorResponse[]; /** Optional additional CloudFront distribution properties */ readonly distributionProps?: AdditionalDistributionProps; /** Optional flag to skip the build process (useful for pre-built artifacts) */ readonly skipBuild?: boolean; /** Optional removal policy for all resources (defaults to DESTROY) */ readonly removalPolicy?: RemovalPolicy; /** * Enable logging and tracing for all supporting resource * @default false */ readonly enableObservability?: boolean; } /** * Frontend construct that deploys a frontend application to S3 and CloudFront * * This construct provides a complete solution for hosting static frontend applications * with the following features: * - S3 bucket for hosting static assets with security best practices * - CloudFront distribution for global content delivery * - Optional custom domain with SSL certificate * - Automatic build process execution * - SPA-friendly error handling by default * - Security configurations */ export declare class Frontend extends Construct { /** The S3 bucket hosting the frontend assets */ readonly bucket: Bucket; /** The CloudFront distribution */ readonly distribution: Distribution; /** The bucket deployment that uploads the frontend assets */ readonly bucketDeployment: BucketDeployment; /** The custom domain name (if configured) */ readonly domainName?: string; /** The Asset containing the frontend source code */ readonly asset?: Asset; /** * Creates a new Frontend * @param scope The construct scope * @param id The construct ID * @param props The frontend properties */ constructor(scope: Construct, id: string, props: FrontendProps); /** * Validates the construct properties * @param props The frontend properties * @private */ private _validateProps; /** * Creates an Asset for the frontend source code with bundling * @param props The frontend properties * @returns The Asset containing the built frontend * @private */ private _createAsset; /** * Creates the CloudFront distribution * @param props The frontend properties * @param removalPolicy The removal policy to apply * @returns The CloudFront distribution * @private */ private _createDistribution; /** * Sets up custom domain with Route53 record * @param customDomain The custom domain configuration * @param removalPolicy The removal policy to apply * @private */ private _setupCustomDomain; /** * Gets the URL of the frontend application * @returns The frontend URL */ url(): string; /** * Gets the CloudFront distribution domain name * @returns The CloudFront domain name */ distributionDomainName(): string; /** * Gets the S3 bucket name * @returns The S3 bucket name */ bucketName(): string; }