amplify-backend icon indicating copy to clipboard operation
amplify-backend copied to clipboard

Add ephemeralStorageSize option to defineFunction

Open fossamagna opened this issue 1 year ago • 2 comments

Environment information

System:
  OS: macOS 14.7
  CPU: (10) arm64 Apple M1 Max
  Memory: 210.70 MB / 32.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
  Yarn: 1.22.19 - ~/.nvm/versions/node/v20.11.1/bin/yarn
  npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
  pnpm: 8.15.6 - ~/.nvm/versions/node/v20.11.1/bin/pnpm
NPM Packages:
  @aws-amplify/auth-construct: 1.5.0
  @aws-amplify/backend: 1.7.0
  @aws-amplify/backend-auth: 1.4.0
  @aws-amplify/backend-cli: 1.4.2
  @aws-amplify/backend-data: 1.2.0
  @aws-amplify/backend-deployer: 1.1.9
  @aws-amplify/backend-function: 1.7.5
  @aws-amplify/backend-output-schemas: 1.4.0
  @aws-amplify/backend-output-storage: 1.1.3
  @aws-amplify/backend-secret: 1.1.4
  @aws-amplify/backend-storage: 1.2.2
  @aws-amplify/cli-core: 1.2.0
  @aws-amplify/client-config: 1.5.2
  @aws-amplify/deployed-backend-client: 1.4.1
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.9
  @aws-amplify/platform-core: 1.2.0
  @aws-amplify/plugin-types: 1.4.0
  @aws-amplify/sandbox: 1.2.5
  @aws-amplify/schema-generator: 1.2.5
  aws-amplify: 6.8.2
  aws-cdk: 2.167.1
  aws-cdk-lib: 2.167.1
  typescript: 5.6.3
No AWS environment variables
No CDK environment variables

Describe the feature

I would like to add an option to defineFunction to specify the size of ephemeral storage.

defineFunction({
  entry: './test-assets/default-lambda/handler.ts',
  ephemeralStorageSize: 1024, // <- like this
})

See:

  • https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html#ephemeralstoragesize
  • https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-ephemeralstorage.html

Use case

When using defineFunction with Amplify Gen2, function has an ephemeral storage size of 512 MB. I will get an error No space left on device when dealing with large size files in Lambda functions. I would like to increase the size of the ephemeral storage with ephemeralStorageSize option.

fossamagna avatar Nov 29 '24 00:11 fossamagna

Hey @fossamagna, thank you for filing this issue and the contribution. Marking this as feature request.

For folks looking to increase this you can override/extend the configuration on the backend.ts filke

const backend = defineBackend({
  myFunction,
});

backend.myFunction.resources.cfnResources.cfnFunction.ephemeralStorage = {
  size: 1024,
};

ykethan avatar Nov 29 '24 15:11 ykethan

@ykethan Thanks for showing us how to do the configuration. I would be happy to review your Pull Request for this issue.

fossamagna avatar Dec 11 '24 02:12 fossamagna

Close this issue as resolved by https://github.com/aws-amplify/amplify-backend/pull/2283.

fossamagna avatar Jun 14 '25 13:06 fossamagna