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

[aws-lambda-event-sources] Unable to use CfnParameter valueAsNumber in KinesisEventSource #9044

Closed
dscpinheiro opened this issue Jul 13, 2020 · 1 comment · Fixed by #9064
Assignees

Comments

@dscpinheiro
Copy link
Contributor

Earlier today, I opened a ticket about being unable to use CfnParameter.valueAsNumber in Kinesis (#9038), and I've run into the same problem on KinesisEventSource

Reproduction Steps

import * as cdk from '@aws-cdk/core';
import * as kinesis from '@aws-cdk/aws-kinesis';
import * as lambda from '@aws-cdk/aws-lambda';

import { KinesisEventSource } from '@aws-cdk/aws-lambda-event-sources';

export class LambdaTestStack extends cdk.Stack {
    constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
        super(scope, id, props);

        const batchSize = new cdk.CfnParameter(this, 'BatchSize', {
            type: 'Number',
            default: 100,
            minValue: 1,
            maxValue: 10000
        });

        const parallelization = new cdk.CfnParameter(this, 'ParallelizationFactor', {
            type: 'Number',
            default: 1,
            minValue: 1,
            maxValue: 10
        });

        const retryAttempts = new cdk.CfnParameter(this, 'MaxRetryAttempts', {
            type: 'Number',
            default: 3,
            minValue: 1,
            maxValue: 10000
        });

        const stream = new kinesis.Stream(this, 'TestStream', {
            shardCount: 2,
            retentionPeriod: cdk.Duration.hours(24)
        });

        const lambdaFn = new lambda.Function(this, 'Function', {
            runtime: lambda.Runtime.NODEJS_12_X,
            handler: 'index.handler',
            code: lambda.Code.fromInline('foo')
        });

        const eventSource = new KinesisEventSource(stream, {
            startingPosition: lambda.StartingPosition.LATEST,
            batchSize: batchSize.valueAsNumber,
            retryAttempts: retryAttempts.valueAsNumber,
            parallelizationFactor: parallelization.valueAsNumber,
            bisectBatchOnError: true
        });

        lambdaFn.addEventSource(eventSource);
    }
}

Error Log

Maximum batch size must be between 1 and 10000 inclusive (given -1.888154589708767e+289)
retryAttempts must be between 0 and 10000 inclusive, got -1.8881545897087667e+289
parallelizationFactor must be between 1 and 10 inclusive, got -1.8881545897087665e+289

Environment

  • CLI Version : 1.51.0
  • Framework Version: 1.51.0
  • Node.js Version: v12.18.1
  • OS : macOS Mojave 10.14.6
  • Language (Version): TypeScript (3.7.2)

Other

Similar issue in SQS: #7126
Another possible related issue: #3448


This is 🐛 Bug Report

@nija-at
Copy link
Contributor

nija-at commented Jul 14, 2020

Fix is in PR - #9064

@nija-at nija-at added p1 and removed needs-triage This issue or PR still needs to be triaged. labels Jul 14, 2020
@mergify mergify bot closed this as completed in #9064 Jul 14, 2020
mergify bot pushed a commit that referenced this issue Jul 14, 2020
…yAttempts & parallelizationFactor fails (#9064)

Code was not accounting for tokens in its validation checks. Added
support for tokens.

fixes #9044

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
curtiseppel pushed a commit to curtiseppel/aws-cdk that referenced this issue Aug 11, 2020
…yAttempts & parallelizationFactor fails (aws#9064)

Code was not accounting for tokens in its validation checks. Added
support for tokens.

fixes aws#9044

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants