Skip to content

Commit

Permalink
feat(lambda): add support for ephemeral storage
Browse files Browse the repository at this point in the history
  • Loading branch information
robertd committed Mar 25, 2022
1 parent d406ead commit 98b8ea2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/@aws-cdk/aws-lambda/lib/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ export interface FunctionOptions extends EventInvokeConfigOptions {
*/
readonly memorySize?: number;

/**
* The size of the function’s /tmp directory.
*
* @default 512
*/
readonly ephemeralStorageSize?: number;

/**
* Initial policy statements to add to the created Lambda Role.
*
Expand Down Expand Up @@ -763,6 +770,7 @@ export class Function extends FunctionBase {
// Token, actually *modifies* the 'environment' map.
environment: Lazy.uncachedAny({ produce: () => this.renderEnvironment() }),
memorySize: props.memorySize,
ephemeralStorage: this.buildEphemeralStorage(props),
vpcConfig: this.configureVpc(props),
deadLetterConfig: this.buildDeadLetterConfig(dlqTopicOrQueue),
tracingConfig: this.buildTracingConfig(props),
Expand Down Expand Up @@ -1128,6 +1136,16 @@ Environment variables can be marked for removal when used in Lambda@Edge by sett
}
}

private buildEphemeralStorage(props: FunctionProps) {
if (props.ephemeralStorageSize === undefined) {
return undefined;
}

return {
size: props.ephemeralStorageSize,
}
}

private buildTracingConfig(props: FunctionProps) {
if (props.tracing === undefined || props.tracing === Tracing.DISABLED) {
return undefined;
Expand Down

0 comments on commit 98b8ea2

Please sign in to comment.