serverless/serverless · error · ServerlessError

LAMBDA_INVALID_MEMORY_SIZE

LAMBDA_INVALID_MEMORY_SIZE

Error message

Memory size of ${effectiveMemory} MB of function "${functionName}" exceeds the limit of 10240 MB for standard functions. Increase is supported only for functions using capacity providers.

What it means

Thrown during Lambda function compilation when a STANDARD Lambda function (no 'capacityProvider') has an effective memory size above 10240 MB (10 GB). The JSON schema allows up to 32 GB to support capacity providers, so this runtime check at functions.js:283-289 enforces the 10 GB ceiling for ordinary Lambda functions with { stack: false }.

Source

Thrown at packages/serverless/lib/plugins/aws/package/compile/functions.js:284

    // function, fail fast with a clear error instead of letting CloudFormation
    // return a generic 400.
    if (
      functionObject.capacityProvider &&
      effectiveMemory < 2048 &&
      (explicitFunctionMemory != null || explicitProviderMemory != null)
    ) {
      throw new ServerlessError(
        `Functions using capacityProvider must have memory size at least 2048 MB; received ${effectiveMemory} for function "${functionName}".`,
        'LAMBDA_MANAGED_INSTANCES_INVALID_MEMORY_SIZE',
        { stack: false },
      )
    }

    // Standard Lambda functions (without capacity provider) are limited to 10240 MB.
    // The schema allows up to 32GB to support capacity providers, so we must enforce
    // the lower limit here for standard functions.
    if (!functionObject.capacityProvider && effectiveMemory > 10240) {
      throw new ServerlessError(
        `Memory size of ${effectiveMemory} MB of function "${functionName}" exceeds the limit of 10240 MB for standard functions. Increase is supported only for functions using capacity providers.`,
        'LAMBDA_INVALID_MEMORY_SIZE',
        { stack: false },
      )
    }

    functionObject.memory = effectiveMemory
    if (!functionObject.timeout) {
      functionObject.timeout = this.serverless.service.provider.timeout || 6
    }

    let artifactFilePath

    if (functionObject.handler) {
      const serviceArtifactFileName =
        this.provider.naming.getServiceArtifactName()
      const functionArtifactFileName =
        this.provider.naming.getFunctionArtifactName(functionName)

View on GitHub (pinned to b9d7ea51c8)

Solutions

  1. Lower memorySize to 10240 or below for standard Lambda functions.
  2. Configure 'capacityProvider' on the function to unlock memory above 10240 MB.
  3. Audit for provider-level memorySize that might be inherited by this standard function.

Example fix

# before
functions:
  myFn:
    handler: index.handler
    memorySize: 12288
# after
functions:
  myFn:
    handler: index.handler
    memorySize: 10240
Defensive patterns

Strategy: validation

Validate before calling

function validateStandardLambdaMemory(functions, provider) {
  const providerMem = provider && provider.memorySize
  for (const [name, fn] of Object.entries(functions || {})) {
    if (fn.capacityProvider) continue
    const mem = fn.memorySize != null ? fn.memorySize : (providerMem != null ? providerMem : 1024)
    if (mem > 10240) {
      throw new Error(`Function ${name}: standard Lambda memory must be <= 10240 MB; got ${mem}`)
    }
  }
}

Prevention

When it happens

Trigger: Setting 'memorySize: 12288' on a function without capacityProvider; or provider-level memorySize > 10240 applied to a standard function.

Common situations: Raising memory assuming standard Lambda supports the same 32 GB ceiling as managed instances; copy-pasting a capacity-provider memorySize onto a standard function; typo (e.g., 11264 instead of 1126).

Related errors


AI-assisted analysis of serverless/serverless@b9d7ea51c8 (2026-08-13). Data as JSON: /api/errors/a77df66d91fb71a8. Report an issue: GitHub.