Skip to content

@aws-cdk/aws-lambda-event-sources: DynamoEventSource batchSize not assignable via CfnParameter #16221

@wswoboda

Description

@wswoboda

When trying to set the batch size of a DynamoEventSource via CfnParameter I get an Error.
Error: Maximum batch size must be between 1 and 1000 inclusive (given -1.8881545897088076e+289)

Reproduction Steps

const batchSizeParameter = new cdk.CfnParameter(this, "DynamicsBatchSize", {
      type: "Number",
      default: 100,
      minValue: 1,
      maxValue: 1000
    });
function.addEventSource(
  new eventSources.DynamoEventSource(bufferTable,
    {
      startingPosition: lambda.StartingPosition.TRIM_HORIZON,
      retryAttempts: 0,
      batchSize: batchSizeParameter.valueAsNumber
    }
  ));
cdk synth

What did you expect to happen?

I expect the batchSize to be configurable via the CfnParameter. I do not pass any parameter value so I expect the default value 100 is set as batchSize.

What actually happened?

/Users/.../deploy/node_modules/@aws-cdk/aws-lambda-event-sources/lib/dynamodb.ts:17
      throw new Error(`Maximum batch size must be between 1 and 1000 inclusive (given ${this.props.batchSize})`);
            ^
Error: Maximum batch size must be between 1 and 1000 inclusive (given -1.8881545897088076e+289)
    at new DynamoEventSource (/Users/wolframswoboda/dev/ds-core/ds-core-dynamics-gateway/deploy/node_modules/@aws-cdk/aws-lambda-event-sources/lib/dynamodb.ts:17:13)
    at MyStack.createExecutionHandlerAndQueue (/Users/wolframswoboda/dev/ds-core/ds-core-dynamics-gateway/deploy/lib/stack.ts:273:7)
    at new MyStack (/Users/wolframswoboda/dev/ds-core/ds-core-dynamics-gateway/deploy/lib/stack.ts:37:63)
    at Object.<anonymous> (/Users/wolframswoboda/dev/ds-core/ds-core-dynamics-gateway/deploy/bin/run-stack.ts:13:1)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Module.m._compile (/Users/wolframswoboda/dev/ds-core/ds-core-dynamics-gateway/deploy/node_modules/ts-node/src/index.ts:1056:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/wolframswoboda/dev/ds-core/ds-core-dynamics-gateway/deploy/node_modules/ts-node/src/index.ts:1059:12)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Function.Module._load (node:internal/modules/cjs/loader:828:14)

Environment

  • **CDK CLI Version : 1.119 **
  • Framework Version: 1.119
  • Node.js Version: v16.0.0
  • OS : MacOS
  • Language (Version): TypeScript (4.3.4)

This is 🐛 Bug Report

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions