Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ephemeralStorageSizeMB option to defineFunction #2283

Merged
merged 8 commits into from
Dec 14, 2024

Conversation

fossamagna
Copy link
Contributor

@fossamagna fossamagna commented Nov 29, 2024

Problem

Issue number, if available:

#2282

Changes

Corresponding docs PR, if applicable:

aws-amplify/docs#8142

Validation

Added test.

Checklist

  • If this PR includes a functional change to the runtime behavior of the code, I have added or updated automated test coverage for this change.
  • If this PR requires a change to the Project Architecture README, I have included that update in this PR.
  • If this PR requires a docs update, I have linked to that docs PR above.
  • If this PR modifies E2E tests, makes changes to resource provisioning, or makes SDK calls, I have run the PR checks with the run-e2e label set.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@fossamagna fossamagna requested review from a team as code owners November 29, 2024 05:21
Copy link

changeset-bot bot commented Nov 29, 2024

🦋 Changeset detected

Latest commit: 847124a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-amplify/backend-function Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@fossamagna fossamagna requested a review from josefaidt December 12, 2024 05:09
josefaidt
josefaidt previously approved these changes Dec 12, 2024
Copy link
Contributor

@josefaidt josefaidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to file this @fossamagna ! Change looks good to me from a dx perspective

@@ -93,6 +93,7 @@ export type FunctionProps = {
entry?: string;
timeoutSeconds?: number;
memoryMB?: number;
ephemeralStorageSize?: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we suffix this with MB ? we do that in property above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some context:
It seems that CDK is just passing through this value:
see https://github.com/aws/aws-cdk/blob/b5c21890cf67ddda78c18eb0425f11a59fcadb34/packages/aws-cdk-lib/aws-lambda/lib/function.ts#L1057
and perhaps multiplies it by 1024 if necessary.
see https://github.com/aws/aws-cdk/blob/62a0638e325024fc0469ed50f9accd448d87bac7/packages/aws-cdk-lib/core/lib/size.ts#L133

But the lambda claims it's MB not MiB here https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-ephemeralstorage.html .

To confirm this. It might be good to deploy lambda with ephemeralStorageSize given to CDK construct and checking what value is printed in the AWS Console.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sobolk
In CloudFormation and AWS Console, the unit of ehpemeralStorageSize for Lambda was MB.
I understood that only CDK uses MiB as a unit and it is appropriate to give MB to the suffix in Amplify.
I fixed the part of JSDoc for ephemeralStorageSizeMB that used MiB has been corrected to MB.
Thank you very much.

@@ -627,7 +627,7 @@ export type CustomClientConfig = {
export const DEFAULT_CLIENT_CONFIG_VERSION: ClientConfigVersion;

// @public
export const generateClientConfig: <T extends "1" | "1.1" | "1.2" | "1.3" | "0">(backendIdentifier: DeployedBackendIdentifier, version: T, awsClientProvider?: AWSClientProvider<{
export const generateClientConfig: <T extends "1.3" | "0" | "1" | "1.1" | "1.2">(backendIdentifier: DeployedBackendIdentifier, version: T, awsClientProvider?: AWSClientProvider<{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes in packages/client-config/API.md and packages/platform-core/API.md are unexpected.

You can either revert these two files.
Or run npm run clean && npm install && npm run build && npm update:api . I.e. re-generate api reports from clean workspace.

@fossamagna fossamagna changed the title Add ephemeralStorageSize option to defineFunction Add ephemeralStorageSizeMB option to defineFunction Dec 13, 2024
sobolk
sobolk previously approved these changes Dec 13, 2024
@sobolk sobolk enabled auto-merge (squash) December 13, 2024 15:13
Copy link
Contributor

@Amplifiyer Amplifiyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, just need one update.

ephemeralStorageSizeMax
)
) {
throw new Error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please throw an AmplifyUserError instead of a regular error. See line 327 for an example
https://github.com/aws-amplify/amplify-backend/pull/2283/files#diff-e354c6c4617ce06e0e16948f4521eca5f9269445265b80ed16720372d336c886R327

@sobolk sobolk disabled auto-merge December 13, 2024 16:00
@sobolk sobolk merged commit d32e4cd into aws-amplify:main Dec 14, 2024
40 checks passed
@fossamagna fossamagna deleted the add-ephemeral-storage-size branch December 17, 2024 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants