Skip to content

Commit

Permalink
rename ephemeralStorageSize to ephemeralStorageSizeMB
Browse files Browse the repository at this point in the history
  • Loading branch information
fossamagna committed Dec 13, 2024
1 parent 6594212 commit c802c7c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .changeset/nasty-tables-heal.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@aws-amplify/backend-function': minor
---

Add ephemeralStorageSize option to defineFunction
Add ephemeralStorageSizeMB option to defineFunction
2 changes: 1 addition & 1 deletion packages/backend-function/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export type FunctionProps = {
entry?: string;
timeoutSeconds?: number;
memoryMB?: number;
ephemeralStorageSize?: number;
ephemeralStorageSizeMB?: number;
environment?: Record<string, string | BackendSecret>;
runtime?: NodeVersion;
schedule?: FunctionSchedule | FunctionSchedule[];
Expand Down
24 changes: 12 additions & 12 deletions packages/backend-function/src/factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,11 @@ void describe('AmplifyFunctionFactory', () => {
);
});

void describe('ephemeralStorageSize property', () => {
void describe('ephemeralStorageSizeMB property', () => {
void it('sets valid ephemeralStorageSize', () => {
const lambda = defineFunction({
entry: './test-assets/default-lambda/handler.ts',
ephemeralStorageSize: 1024,
ephemeralStorageSizeMB: 1024,
}).getInstance(getInstanceProps);
const template = Template.fromStack(lambda.stack);

Expand All @@ -696,7 +696,7 @@ void describe('AmplifyFunctionFactory', () => {
});
});

void it('sets default ephemeralStorageSize', () => {
void it('sets default ephemeralStorageSizeMB', () => {
const lambda = defineFunction({
entry: './test-assets/default-lambda/handler.ts',
}).getInstance(getInstanceProps);
Expand All @@ -707,41 +707,41 @@ void describe('AmplifyFunctionFactory', () => {
});
});

void it('throws on ephemeralStorageSize below 512 MB', () => {
void it('throws on ephemeralStorageSizeMB below 512 MB', () => {
assert.throws(
() =>
defineFunction({
entry: './test-assets/default-lambda/handler.ts',
ephemeralStorageSize: 511,
ephemeralStorageSizeMB: 511,
}).getInstance(getInstanceProps),
new Error(
'ephemeralStorageSize must be a whole number between 512 and 10240 inclusive'
'ephemeralStorageSizeMB must be a whole number between 512 and 10240 inclusive'
)
);
});

void it('throws on ephemeralStorageSize above 10240 MB', () => {
void it('throws on ephemeralStorageSizeMB above 10240 MB', () => {
assert.throws(
() =>
defineFunction({
entry: './test-assets/default-lambda/handler.ts',
ephemeralStorageSize: 10241,
ephemeralStorageSizeMB: 10241,
}).getInstance(getInstanceProps),
new Error(
'ephemeralStorageSize must be a whole number between 512 and 10240 inclusive'
'ephemeralStorageSizeMB must be a whole number between 512 and 10240 inclusive'
)
);
});

void it('throws on fractional ephemeralStorageSize', () => {
void it('throws on fractional ephemeralStorageSizeMB', () => {
assert.throws(
() =>
defineFunction({
entry: './test-assets/default-lambda/handler.ts',
ephemeralStorageSize: 512.5,
ephemeralStorageSizeMB: 512.5,
}).getInstance(getInstanceProps),
new Error(
'ephemeralStorageSize must be a whole number between 512 and 10240 inclusive'
'ephemeralStorageSizeMB must be a whole number between 512 and 10240 inclusive'
)
);
});
Expand Down
16 changes: 8 additions & 8 deletions packages/backend-function/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ export type FunctionProps = {
memoryMB?: number;

/**
* The size of the function's /tmp directory in MiB.
* The size of the function's /tmp directory in MB.
* Must be a whole number.
* @default 512
*/
ephemeralStorageSize?: number;
ephemeralStorageSizeMB?: number;

/**
* Environment variables that will be available during function execution
Expand Down Expand Up @@ -243,7 +243,7 @@ class FunctionFactory implements ConstructFactory<AmplifyFunction> {
entry: this.resolveEntry(),
timeoutSeconds: this.resolveTimeout(),
memoryMB: this.resolveMemory(),
ephemeralStorageSize: this.resolveEphemeralStorageSize(),
ephemeralStorageSizeMB: this.resolveEphemeralStorageSize(),
environment: this.resolveEnvironment(),
runtime: this.resolveRuntime(),
schedule: this.resolveSchedule(),
Expand Down Expand Up @@ -336,21 +336,21 @@ class FunctionFactory implements ConstructFactory<AmplifyFunction> {
const ephemeralStorageSizeMin = 512;
const ephemeralStorageSizeMax = 10240;
const ephemeralStorageSizeDefault = 512;
if (this.props.ephemeralStorageSize === undefined) {
if (this.props.ephemeralStorageSizeMB === undefined) {
return ephemeralStorageSizeDefault;
}
if (
!isWholeNumberBetweenInclusive(
this.props.ephemeralStorageSize,
this.props.ephemeralStorageSizeMB,
ephemeralStorageSizeMin,
ephemeralStorageSizeMax
)
) {
throw new Error(
`ephemeralStorageSize must be a whole number between ${ephemeralStorageSizeMin} and ${ephemeralStorageSizeMax} inclusive`
`ephemeralStorageSizeMB must be a whole number between ${ephemeralStorageSizeMin} and ${ephemeralStorageSizeMax} inclusive`
);
}
return this.props.ephemeralStorageSize;
return this.props.ephemeralStorageSizeMB;
};

private resolveEnvironment = () => {
Expand Down Expand Up @@ -538,7 +538,7 @@ class AmplifyFunction
entry: props.entry,
timeout: Duration.seconds(props.timeoutSeconds),
memorySize: props.memoryMB,
ephemeralStorageSize: Size.mebibytes(props.ephemeralStorageSize),
ephemeralStorageSize: Size.mebibytes(props.ephemeralStorageSizeMB),

Check warning on line 541 in packages/backend-function/src/factory.ts

View workflow job for this annotation

GitHub Actions / lint

You have a misspelled word: mebibytes on Identifier
runtime: nodeVersionMap[props.runtime],
layers: props.resolvedLayers,
bundling: {
Expand Down

0 comments on commit c802c7c

Please sign in to comment.