File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
packages/@aws-cdk/aws-lambda Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -382,14 +382,18 @@ export class EventSourceMapping extends cdk.Resource implements IEventSourceMapp
382
382
}
383
383
384
384
private validateKafkaConsumerGroupIdOrThrow ( kafkaConsumerGroupId : string ) {
385
+ if ( cdk . Token . isUnresolved ( kafkaConsumerGroupId ) ) {
386
+ return ;
387
+ }
388
+
385
389
if ( kafkaConsumerGroupId . length > 200 || kafkaConsumerGroupId . length < 1 ) {
386
390
throw new Error ( 'kafkaConsumerGroupId must be a valid string between 1 and 200 characters' ) ;
387
391
}
388
392
389
393
const regex = new RegExp ( / [ a - z A - Z 0 - 9 -\/ * : _ + = . @ - ] * / ) ;
390
394
const patternMatch = regex . exec ( kafkaConsumerGroupId ) ;
391
395
if ( patternMatch === null || patternMatch [ 0 ] !== kafkaConsumerGroupId ) {
392
- throw new Error ( 'kafkaConsumerGroupId contain ivalid characters. Allowed values are "[a-zA-Z0-9-\/*:_+=.@-]"' ) ;
396
+ throw new Error ( 'kafkaConsumerGroupId contains invalid characters. Allowed values are "[a-zA-Z0-9-\/*:_+=.@-]"' ) ;
393
397
}
394
398
}
395
399
}
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ describe('event source mapping', () => {
159
159
eventSourceArn : 'arn:aws:kafka:us-east-1:123456789012:cluster/vpc-2priv-2pub/751d2973-a626-431c-9d4e-d7975eb44dd7-2' ,
160
160
kafkaConsumerGroupId : 'some invalid' ,
161
161
target : fn ,
162
- } ) ) . toThrow ( 'kafkaConsumerGroupId contain ivalid characters. Allowed values are "[a-zA-Z0-9-\/*:_+=.@-]"' ) ;
162
+ } ) ) . toThrow ( 'kafkaConsumerGroupId contains invalid characters. Allowed values are "[a-zA-Z0-9-\/*:_+=.@-]"' ) ;
163
163
} ) ;
164
164
165
165
test ( 'throws if kafkaConsumerGroupId is too long' , ( ) => {
@@ -178,6 +178,14 @@ describe('event source mapping', () => {
178
178
} ) ) . not . toThrow ( ) ;
179
179
} ) ;
180
180
181
+ test ( 'not throws if kafkaConsumerGroupId is token' , ( ) => {
182
+ expect ( ( ) => new EventSourceMapping ( stack , 'test' , {
183
+ eventSourceArn : 'arn:aws:kafka:us-east-1:123456789012:cluster/vpc-2priv-2pub/751d2973-a626-431c-9d4e-d7975eb44dd7-2' ,
184
+ kafkaConsumerGroupId : cdk . Lazy . string ( { produce : ( ) => 'test' } ) ,
185
+ target : fn ,
186
+ } ) ) . not . toThrow ( ) ;
187
+ } ) ;
188
+
181
189
test ( 'not throws if kafkaConsumerGroupId is valid for amazon managed kafka' , ( ) => {
182
190
expect ( ( ) => new EventSourceMapping ( stack , 'test' , {
183
191
eventSourceArn : 'arn:aws:kafka:us-east-1:123456789012:cluster/vpc-2priv-2pub/751d2973-a626-431c-9d4e-d7975eb44dd7-2' ,
You can’t perform that action at this time.
0 commit comments