import { AmplifyResourceGroupName, BackendSecret, ConstructFactory, FunctionResources, LogLevel, LogRetention, ResourceAccessAcceptorFactory, ResourceProvider, StackProvider } from '@aws-amplify/plugin-types'; import { IFunction } from 'aws-cdk-lib/aws-lambda'; import { Construct } from 'constructs'; import { ProvidedFunctionProps } from './provided_function_factory.js'; export type AddEnvironmentFactory = { addEnvironment: (key: string, value: string | BackendSecret) => void; }; export type CronScheduleExpression = `${string} ${string} ${string} ${string} ${string}` | `${string} ${string} ${string} ${string} ${string} ${string}`; export type ZonedCronSchedule = { cron: CronScheduleExpression; timezone: string; description?: string; }; export type CronSchedule = CronScheduleExpression | ZonedCronSchedule; export type TimeIntervalExpression = `every ${number}m` | `every ${number}h` | `every day` | `every week` | `every month` | `every year`; export type ZonedTimeInterval = { rate: TimeIntervalExpression; timezone: string; description?: string; }; export type TimeInterval = ZonedTimeInterval | TimeIntervalExpression; export type FunctionSchedule = TimeInterval | CronSchedule; export type FunctionLogLevel = Extract; export type FunctionLogRetention = LogRetention; export declare function defineFunction(props?: FunctionProps): ConstructFactory & ResourceAccessAcceptorFactory & AddEnvironmentFactory & StackProvider>; export declare function defineFunction(provider: (scope: Construct) => IFunction, providerProps?: ProvidedFunctionProps): ConstructFactory & ResourceAccessAcceptorFactory & AddEnvironmentFactory & StackProvider>; export type FunctionProps = { /** * A name for the function. * Defaults to the basename of the entry path if specified. * If no entry is specified, defaults to the directory name in which this function is defined. * * Example: * If entry is `./scheduled-db-backup.ts` the name will default to "scheduled-db-backup" * If entry is not set and the function is defined in `amplify/functions/db-backup/resource.ts` the name will default to "db-backup" */ name?: string; /** * The path to the file that contains the function entry point. * If this is a relative path, it is computed relative to the file where this function is defined * * Defaults to './handler.ts' */ entry?: string; /** * An amount of time in seconds between 1 second and 15 minutes. * Must be a whole number. * Default is 3 seconds. */ timeoutSeconds?: number; /** * An amount of memory (RAM) to allocate to the function between 128 and 10240 MB. * Must be a whole number. * Default is 512MB. */ memoryMB?: number; /** * The size of the function's /tmp directory in MB. * Must be a whole number. * @default 512 */ ephemeralStorageSizeMB?: number; /** * Environment variables that will be available during function execution */ environment?: Record; /** * Node runtime version for the lambda environment. * * Defaults to the oldest NodeJS LTS version. See https://nodejs.org/en/about/previous-releases */ runtime?: NodeVersion; /** * The architecture of the target platform for the lambda environment. * Defaults to X86_64. */ architecture?: FunctionArchitecture; /** * A time interval string to periodically run the function. * This can be either a string of `"every "`, `"every day|week|month|year"` or cron expression. * Defaults to no scheduling for the function. * @example * schedule: "every 5m" * @example * schedule: "every week" * @example * schedule: "0 9 ? * 2 *" // every Monday at 9am */ schedule?: FunctionSchedule | FunctionSchedule[]; /** * Attach Lambda layers to a function * - A Lambda layer is represented by an object of key/value pair where the key is the module name that is exported from your layer and the value is the ARN of the layer. The key (module name) is used to externalize the module dependency so it doesn't get bundled with your lambda function * - Maximum of 5 layers can be attached to a function and must be in the same region as the function. * @example * layers: { * "@aws-lambda-powertools/logger": "arn:aws:lambda::094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:11" * }, * or * @example * layers: { * "Sharp": "SharpLayer:1" * }, * @see [Amplify documentation for Lambda layers](https://docs.amplify.aws/react/build-a-backend/functions/add-lambda-layers) * @see [AWS documentation for Lambda layers](https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html) */ layers?: Record; bundling?: FunctionBundlingOptions; /** * Group the function with existing Amplify resources or separate the function into its own group. * @default 'function' // grouping with other Amplify functions * @example * resourceGroupName: 'auth' // to group an auth trigger with an auth resource */ resourceGroupName?: AmplifyResourceGroupName; logging?: FunctionLoggingOptions; /** * Configuration for durable functions. * * Lambda durable functions allow for long-running executions with persistent state. */ durableConfig?: FunctionDurableConfigOptions; }; export type FunctionBundlingOptions = { /** * Whether to minify the function code. * * Defaults to true. */ minify?: boolean; }; export type FunctionLoggingOptions = ({ format: 'json'; level?: FunctionLogLevel; } | { format?: 'text'; }) & { retention?: FunctionLogRetention; }; export type FunctionDurableConfigOptions = { /** * The amount of time in seconds that Lambda allows a durable function to run before stopping it. * * Must be between 1 and 31,622,400 seconds (366 days). */ executionTimeoutSeconds: number; /** * The number of days after a durable execution is closed that Lambda retains its history. * * Must be between 1 and 90 days. * @default 14 */ retentionPeriodDays?: number; }; export type NodeVersion = 18 | 20 | 22 | 24; export type FunctionArchitecture = 'x86_64' | 'arm64'; //# sourceMappingURL=factory.d.ts.map