import * as cdk from "aws-cdk-lib"; import * as lambda from "aws-cdk-lib/aws-lambda"; import * as cxapi from "aws-cdk-lib/cx-api"; import { Bootstrap } from "@serverless-stack/core"; import { SSTConstruct } from "./Construct.js"; import { FunctionProps, FunctionHandlerProps } from "./Function.js"; import * as Config from "./Config.js"; import { BaseSiteEnvironmentOutputsInfo } from "./BaseSite.js"; import { Permissions } from "./util/permission.js"; import { StackProps } from "./Stack.js"; import { FunctionalStack } from "./FunctionalStack.js"; /** * @internal */ export interface AppDeployProps { /** * The app name, used to prefix stacks. * * @default - Defaults to empty string */ readonly name?: string; /** * The stage to deploy this app to. * * @default - Defaults to dev */ readonly stage?: string; /** * The region to deploy this app to. * * @default - Defaults to us-east-1 */ readonly region?: string; readonly buildDir?: string; readonly skipBuild?: boolean; readonly ssmPrefix?: string; readonly esbuildConfig?: string; readonly bootstrapAssets?: Bootstrap.Assets; readonly debugEndpoint?: string; readonly debugBucketArn?: string; readonly debugBucketName?: string; readonly debugStartedAt?: number; readonly debugBridge?: string; readonly debugIncreaseTimeout?: boolean; /** * The callback after synth completes, used by `sst start`. * * @default - Defaults to undefined */ readonly synthCallback?: (lambdaHandlers: FunctionHandlerProps[], siteEnvironments: BaseSiteEnvironmentOutputsInfo[]) => void; } declare type AppRemovalPolicy = Lowercase; declare type AppWarningType = "usingConfig" | "usingPermissionsWithSSTConstruct" | "usingApiPothosRoute" | "usingGraphQLApi" | "usingReactStaticSite" | "usingViteStaticSite"; export declare type AppProps = cdk.AppProps; /** * The App construct extends cdk.App and is used internally by SST. */ export declare class App extends cdk.App { /** * Whether or not the app is running locally under `sst start` */ readonly local: boolean; /** * The name of your app, comes from the `name` in your `sst.json` */ readonly name: string; /** * The stage the app is being deployed to. If this is not specified as the --stage option, it'll default to the stage configured during the initial run of the SST CLI. */ readonly stage: string; /** * The region the app is being deployed to. If this is not specified as the --region option in the SST CLI, it'll default to the region in your sst.json. */ readonly region: string; /** * The AWS account the app is being deployed to. This comes from the IAM credentials being used to run the SST CLI. */ readonly account: string; /** @internal */ readonly buildDir: string; /** @internal */ readonly esbuildConfig?: string; /** @internal */ readonly bootstrapAssets: Bootstrap.Assets; /** @internal */ readonly debugBridge?: string; /** @internal */ readonly debugEndpoint?: string; /** @internal */ readonly debugBucketArn?: string; /** @internal */ readonly debugBucketName?: string; /** @internal */ readonly debugStartedAt?: number; /** @internal */ readonly debugIncreaseTimeout?: boolean; /** @internal */ readonly appPath: string; /** @internal */ defaultFunctionProps: (FunctionProps | ((stack: cdk.Stack) => FunctionProps))[]; private _defaultRemovalPolicy?; /** @internal */ get defaultRemovalPolicy(): "destroy" | "retain" | "snapshot" | undefined; /** * The callback after synth completes. */ private readonly synthCallback?; /** * A list of Lambda functions in the app */ private readonly lambdaHandlers; private readonly siteEnvironments; /** * Skip building Function code * Note that on `sst remove`, we do not want to bundle the Lambda functions. * CDK disables bundling (ie. zipping) for `cdk destroy` command. * But SST runs `cdk synth` first then manually remove each stack. Hence * we cannot rely on CDK to disable bundling, and we disable it manually. * This allows us to disable BOTH building and bundling, where as CDK * would only disable the latter. For example, `cdk destroy` still trys * to install Python dependencies in Docker. * * @internal */ readonly skipBuild: boolean; /** @internal */ private warnings; /** * @internal */ constructor(deployProps?: AppDeployProps, props?: AppProps); /** * Use this method to prefix resource names in your stacks to make sure they don't thrash when deployed to different stages in the same AWS account. This method will prefix a given resource name with the stage and app name. Using the format `${stage}-${name}-${logicalName}`. * @example * ```js * console.log(app.logicalPrefixedName("myTopic")); * * // dev-my-app-myTopic * ``` */ logicalPrefixedName(logicalName: string): string; /** * The default removal policy that'll be applied to all the resources in the app. This can be useful to set ephemeral (dev or feature branch) environments to remove all the resources on deletion. * :::danger * Make sure to not set the default removal policy to `DESTROY` for production environments. * ::: * @example * ```js * app.setDefaultRemovalPolicy(app.local ? "destroy" : "retain") * ``` */ setDefaultRemovalPolicy(policy: AppRemovalPolicy): void; /** * The default function props to be applied to all the Lambda functions in the app. These default values will be overridden if a Function sets its own props. * This needs to be called before a stack with any functions have been added to the app. * * @example * ```js * app.setDefaultFunctionProps({ * runtime: "nodejs12.x", * timeout: 30 * }) * ``` */ setDefaultFunctionProps(props: FunctionProps | ((stack: cdk.Stack) => FunctionProps)): void; /** * Adds additional default Permissions to be applied to all Lambda functions in the app. * * @example * ```js * app.addDefaultFunctionPermissions(["s3"]) * ``` */ addDefaultFunctionPermissions(permissions: Permissions): void; /** * Adds additional default environment variables to be applied to all Lambda functions in the app. * * @example * ```js * app.addDefaultFunctionPermissions({ * "MY_ENV_VAR": "my-value" * }) * ``` */ addDefaultFunctionEnv(environment: Record): void; /** * Adds additional default config to be applied to all Lambda functions in the app. * * @deprecated The "addDefaultFunctionConfig" method will be removed in SST v2. Pass Parameters and Secrets in through the "addDefaultFunctionBinding" function. Read more about how to upgrade here — https://docs.sst.dev/upgrade-guide#upgrade-to-v116 * * @example * ```js * // Change * app.addDefaultFunctionConfig([STRIPE_KEY]); * * // To * app.addDefaultFunctionBinding([STRIPE_KEY]); * ``` */ addDefaultFunctionConfig(config: (Config.Secret | Config.Parameter)[]): void; /** * Binds additional default resources to be applied to all Lambda functions in the app. * * @example * ```js * app.addDefaultFunctionBinding([STRIPE_KEY, bucket]); * ``` */ addDefaultFunctionBinding(bind: SSTConstruct[]): void; /** * Adds additional default layers to be applied to all Lambda functions in the stack. */ addDefaultFunctionLayers(layers: lambda.ILayerVersion[]): void; synth(options?: cdk.StageSynthesisOptions): cxapi.CloudAssembly; runDeferredBuilds(): Promise; isRunningSSTTest(): boolean; registerLambdaHandler(handler: FunctionHandlerProps): void; registerSiteEnvironment(environment: BaseSiteEnvironmentOutputsInfo): void; getInputFilesFromEsbuildMetafile(file: string): Array; private buildConstructsMetadata; private buildConstructsMetadata_collectConstructs; private applyRemovalPolicy; private removeGovCloudUnsupportedResourceProperties; private ensureUniqueConstructIds; private codegenBindingTypes; private codegenFindNodeModulesPath; private codegenCreateIndexType; private codegenCreateConstructTypes; private createBindingSsmParameters; /** @internal */ reportWarning(type: AppWarningType): void; private printWarnings; stack>(fn: T, props?: StackProps & { id?: string; }): ReturnType extends Promise ? Promise : App; } export {};