import { Construct } from "constructs"; import * as s3 from "aws-cdk-lib/aws-s3"; import * as lambda from "aws-cdk-lib/aws-lambda"; import * as route53 from "aws-cdk-lib/aws-route53"; import * as cloudfront from "aws-cdk-lib/aws-cloudfront"; import * as acm from "aws-cdk-lib/aws-certificatemanager"; import { SSTConstruct } from "./Construct.js"; import { BaseSiteDomainProps, BaseSiteCdkDistributionProps } from "./BaseSite.js"; import { Permissions } from "./util/permission.js"; import { FunctionBindingProps } from "./util/functionBinding.js"; export interface RemixDomainProps extends BaseSiteDomainProps { } export interface RemixCdkDistributionProps extends BaseSiteCdkDistributionProps { } export interface RemixSiteProps { /** * The Remix app server is deployed to a Lambda function in a single region. Alternatively, you can enable this option to deploy to Lambda@Edge. * * @default false */ edge?: boolean; /** * Path to the directory where the website source is located. */ path: string; /** * The customDomain for this website. SST supports domains that are hosted * either on [Route 53](https://aws.amazon.com/route53/) or externally. * * Note that you can also migrate externally hosted domains to Route 53 by * [following this guide](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/MigratingDNS.html). * * @example * ```js {3} * new RemixSite(stack, "RemixSite", { * path: "path/to/site", * customDomain: "domain.com", * }); * ``` * * ```js {3-6} * new RemixSite(stack, "RemixSite", { * path: "path/to/site", * customDomain: { * domainName: "domain.com", * domainAlias: "www.domain.com", * hostedZone: "domain.com" * }, * }); * ``` */ customDomain?: string | RemixDomainProps; /** * An object with the key being the environment variable name. * * @example * ```js {3-6} * new RemixSite(stack, "RemixSite", { * path: "path/to/site", * environment: { * API_URL: api.url, * USER_POOL_CLIENT: auth.cognitoUserPoolClient.userPoolClientId, * }, * }); * ``` */ environment?: Record; /** * When running `sst start`, a placeholder site is deployed. This is to ensure * that the site content remains unchanged, and subsequent `sst start` can * start up quickly. * * @example * ```js {3} * new RemixSite(stack, "RemixSite", { * path: "path/to/site", * disablePlaceholder: true, * }); * ``` */ disablePlaceholder?: boolean; defaults?: { function?: { timeout?: number; memorySize?: number; permissions?: Permissions; }; }; /** * While deploying, SST waits for the CloudFront cache invalidation process to finish. This ensures that the new content will be served once the deploy command finishes. However, this process can sometimes take more than 5 mins. For non-prod environments it might make sense to pass in `false`. That'll skip waiting for the cache to invalidate and speed up the deploy process. */ waitForInvalidation?: boolean; cdk?: { /** * Allows you to override default id for this construct. */ id?: string; /** * Allows you to override default settings this construct uses internally to ceate the bucket */ bucket?: s3.BucketProps | s3.IBucket; /** * Pass in a value to override the default settings this construct uses to * create the CDK `Distribution` internally. */ distribution?: RemixCdkDistributionProps; /** * Override the default CloudFront cache policies created internally. */ cachePolicies?: { /** * Override the CloudFront cache policy properties for browser build files. */ buildCachePolicy?: cloudfront.ICachePolicy; /** * Override the CloudFront cache policy properties for "public" folder * static files. * * Note: This will not include the browser build files, which have a seperate * cache policy; @see `buildCachePolicy`. */ staticsCachePolicy?: cloudfront.ICachePolicy; /** * Override the CloudFront cache policy properties for responses from the * server rendering Lambda. * * @note The default cache policy that is used in the abscene of this property * is one that performs no caching of the server response. */ serverCachePolicy?: cloudfront.ICachePolicy; }; }; } /** * The `RemixSite` construct is a higher level CDK construct that makes it easy to create a Remix app. * * @example * * Deploys a Remix app in the `my-remix-app` directory. * * ```js * new RemixSite(stack, "web", { * path: "my-remix-app/", * }); * ``` */ export declare class RemixSite extends Construct implements SSTConstruct { readonly id: string; /** * The default CloudFront cache policy properties for browser build files. */ static buildCachePolicyProps: cloudfront.CachePolicyProps; /** * The default CloudFront cache policy properties for "public" folder * static files. * * @note This policy is not applied to the browser build files; they have a seperate * cache policy; @see `buildCachePolicyProps`. */ static staticsCachePolicyProps: cloudfront.CachePolicyProps; /** * The default CloudFront cache policy properties for responses from the * server rendering Lambda. * * @note By default no caching is performed on the server rendering Lambda response. */ static serverCachePolicyProps: cloudfront.CachePolicyProps; /** * Exposes CDK instances created within the construct. */ readonly cdk: { /** * The internally created CDK `Function` instance. Not available in the "edge" mode. */ function?: lambda.Function; /** * The internally created CDK `Bucket` instance. */ bucket: s3.Bucket; /** * The internally created CDK `Distribution` instance. */ distribution: cloudfront.Distribution; /** * The Route 53 hosted zone for the custom domain. */ hostedZone?: route53.IHostedZone; /** * The AWS Certificate Manager certificate for the custom domain. */ certificate?: acm.ICertificate; }; private props; /** * Determines if a placeholder site should be deployed instead. We will set * this to `true` by default when performing local development, although the * user can choose to override this value. */ private isPlaceholder; /** * The root SST directory used for builds. */ private sstBuildDir; /** * The remix site config. It contains user configuration overrides which we * will need to consider when resolving Remix's build output. */ private remixConfig; private serverLambdaForEdge?; private serverLambdaForRegional?; private awsCliLayer; constructor(scope: Construct, id: string, props: RemixSiteProps); /** * The CloudFront URL of the website. */ get url(): string; /** * If the custom domain is enabled, this is the URL of the website with the * custom domain. */ get customDomainUrl(): string | undefined; /** * The ARN of the internally created S3 Bucket. */ get bucketArn(): string; /** * The name of the internally created S3 Bucket. */ get bucketName(): string; /** * The ID of the internally created CloudFront Distribution. */ get distributionId(): string; /** * The domain name of the internally created CloudFront Distribution. */ get distributionDomain(): string; /** * Attaches the given list of permissions to allow the Remix server side * rendering to access other AWS resources. * * @example * ```js {5} * const site = new RemixSite(stack, "Site", { * path: "path/to/site", * }); * * site.attachPermissions(["sns"]); * ``` */ attachPermissions(permissions: Permissions): void; getConstructMetadata(): { type: "RemixSite"; data: { distributionId: string; customDomainUrl: string | undefined; }; }; /** @internal */ getFunctionBinding(): FunctionBindingProps; private buildApp; private runNpmBuild; private createStaticsS3Assets; private createStaticsS3AssetsWithStub; private createS3Bucket; private createS3Deployment; private createServerLambdaBundleForRegional; private createServerLambdaBundleForEdge; private createServerLambdaBundle; private createServerLambdaBundleWithStub; private createServerFunctionForRegional; private createServerFunctionForEdge; private validateCloudFrontDistributionSettings; private createCloudFrontDistributionForRegional; private createCloudFrontDistributionForEdge; private createCloudFrontDistributionForStub; private buildDistributionDomainNames; private buildDistributionDefaultBehaviorForRegional; private buildDistributionDefaultBehaviorForEdge; private buildDistributionStaticBehaviors; private createCloudFrontBuildAssetsCachePolicy; private createCloudFrontStaticsCachePolicy; private createCloudFrontServerCachePolicy; private createCloudFrontInvalidation; protected validateCustomDomainSettings(): void; protected lookupHostedZone(): route53.IHostedZone | undefined; private createCertificate; protected createRoute53Records(): void; private registerSiteEnvironment; private readRemixConfig; private generateBuildId; }