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

fix(lambda-event-sources): event source property maxConcurrency is not token-aware #27797

Merged
merged 4 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export class EventSourceMapping extends cdk.Resource implements IEventSourceMapp
throw new Error(`maxBatchingWindow cannot be over 300 seconds, got ${props.maxBatchingWindow.toSeconds()}`);
}

if (props.maxConcurrency && (props.maxConcurrency < 2 || props.maxConcurrency > 1000)) {
if (props.maxConcurrency && !cdk.Token.isUnresolved(props.maxConcurrency) && (props.maxConcurrency < 2 || props.maxConcurrency > 1000)) {
throw new Error('maxConcurrency must be between 2 and 1000 concurrent instances');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ describe('event source mapping', () => {
})).toThrow(/maxConcurrency must be between 2 and 1000 concurrent instances/);
});

test('does not throw if maxConcurrency is a token', () => {
expect(() => new EventSourceMapping(stack, 'test', {
target: fn,
eventSourceArn: '',
maxConcurrency: cdk.Token.asNumber({ Ref: 'abc' }),
})).not.toThrow();
});

test('maxConcurrency appears in stack', () => {
new EventSourceMapping(stack, 'test', {
target: fn,
Expand Down
Loading