import { Stack } from "./Stack.js"; import { SSTConstruct } from "./Construct.js"; import { FunctionProps } from "./Function.js"; import { Permissions } from "./util/permission.js"; import { BindingResource } from "./util/binding.js"; import { StackProps } from "./Stack.js"; import { FunctionalStack } from "./FunctionalStack.js"; import { AppProps as CDKAppProps, App as CDKApp, Stack as CDKStack, RemovalPolicy } from "aws-cdk-lib/core"; import { ILayerVersion } from "aws-cdk-lib/aws-lambda"; /** * @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 account?: string; readonly debugScriptVersion?: string; readonly debugIncreaseTimeout?: boolean; readonly mode: "deploy" | "dev" | "remove"; readonly isActiveStack?: (stackName: string) => boolean; } type AppRemovalPolicy = Lowercase; export type AppProps = CDKAppProps; /** * The App construct extends cdk.App and is used internally by SST. */ export declare class App extends CDKApp { /** * Whether or not the app is running locally under `sst dev` */ readonly local: boolean; /** * Whether the app is running locally under start, deploy or remove */ readonly mode: AppDeployProps["mode"]; /** * The name of your app, comes from the `name` in your `sst.config.ts` */ 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.config.ts. */ 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 debugScriptVersion?: string; /** @internal */ readonly debugIncreaseTimeout?: boolean; /** @internal */ readonly appPath: string; /** @internal */ readonly isActiveStack?: (stackName: string) => boolean; /** @internal */ defaultFunctionProps: (FunctionProps | ((stack: Stack) => FunctionProps))[]; private _defaultRemovalPolicy?; /** @internal */ get defaultRemovalPolicy(): "destroy" | "retain" | "snapshot" | "retain-on-update-or-delete" | undefined; /** * @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.mode === "dev" ? "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: "nodejs20.x", * timeout: 30 * }) * ``` */ setDefaultFunctionProps(props: FunctionProps | ((stack: CDKStack) => 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.addDefaultFunctionEnv({ * "MY_ENV_VAR": "my-value" * }) * ``` */ addDefaultFunctionEnv(environment: Record): void; /** * Binds additional default resources to be applied to all Lambda functions in the app. * * @example * ```js * app.addDefaultFunctionBinding([STRIPE_KEY, bucket]); * ``` */ addDefaultFunctionBinding(bind: BindingResource[]): void; /** * Adds additional default layers to be applied to all Lambda functions in the stack. */ addDefaultFunctionLayers(layers: ILayerVersion[]): void; private useTypesPath; private createTypesFile; registerTypes(c: SSTConstruct): void; private isFinished; finish(): Promise; isRunningSSTTest(): boolean; getInputFilesFromEsbuildMetafile(file: string): Array; private createBindingSsmParameters; private buildConstructsMetadata; private buildConstructsMetadata_collectConstructs; private applyRemovalPolicy; private removeGovCloudUnsupportedResourceProperties; private ensureUniqueConstructIds; private foreachConstruct; stack>(fn: T, props?: StackProps & { id?: string; }): ReturnType extends Promise ? Promise : App; } export {};