@@ -409,10 +409,11 @@ def create(self):
409
409
410
410
if LambdaPremissionPrefix and LambdaPremissionPrefix != ["" ]:
411
411
for prefix in LambdaPremissionPrefix :
412
+ replaced_prefix = self .check_statmentid_length (prefix )
412
413
try :
413
414
self .aws_lambda .add_permission (
414
415
FunctionName = lambda_arn ,
415
- StatementId = f'allow-trigger-from-{ prefix .replace ("/" , "-" )} -log-groups' ,
416
+ StatementId = f'allow-trigger-from-{ replaced_prefix .replace ("/" , "-" )} -log-groups' ,
416
417
Action = 'lambda:InvokeFunction' ,
417
418
Principal = 'logs.amazonaws.com' ,
418
419
SourceArn = f'arn:aws:logs:{ region } :{ account_id } :log-group:{ prefix } *:*' ,
@@ -427,9 +428,10 @@ def create(self):
427
428
)
428
429
if not LambdaPremissionPrefix or LambdaPremissionPrefix == ["" ]:
429
430
if not response .get ("subscriptionFilters" ) or response .get ("subscriptionFilters" )[0 ].get ("destinationArn" ) != lambda_arn :
431
+ replaced_prefix = self .check_statmentid_length (log_group )
430
432
response = self .aws_lambda .add_permission (
431
433
FunctionName = lambda_arn ,
432
- StatementId = f'allow-trigger-from-{ log_group .replace ("/" , "-" )} ' ,
434
+ StatementId = f'allow-trigger-from-{ replaced_prefix .replace ("/" , "-" )} ' ,
433
435
Action = 'lambda:InvokeFunction' ,
434
436
Principal = 'logs.amazonaws.com' ,
435
437
SourceArn = f'arn:aws:logs:{ region } :{ account_id } :log-group:{ log_group } :*' ,
@@ -442,6 +444,15 @@ def create(self):
442
444
logGroupName = log_group
443
445
)
444
446
447
+ @handle_exceptions
448
+ def check_statmentid_length (self , statmentid_prefix ):
449
+ updated_prefix = statmentid_prefix
450
+ if len (statmentid_prefix ) >= 70 : # StatementId length limit is 100
451
+ updated_prefix = statmentid_prefix [:65 ] + statmentid_prefix [- 5 :]
452
+ else :
453
+ updated_prefix = statmentid_prefix
454
+ return updated_prefix
455
+
445
456
@handle_exceptions
446
457
def update (self ):
447
458
err = self .delete ()
@@ -466,9 +477,10 @@ def delete(self):
466
477
logGroupName = log_group
467
478
)
468
479
if not LambdaPremissionPrefix :
480
+ replaced_prefix = self .check_statmentid_length (log_group )
469
481
response = self .aws_lambda .remove_permission (
470
482
FunctionName = lambda_arn ,
471
- StatementId = f'allow-trigger-from-{ log_group .replace ("/" , "-" )} '
483
+ StatementId = f'allow-trigger-from-{ replaced_prefix .replace ("/" , "-" )} '
472
484
)
473
485
474
486
def handle (self ):
0 commit comments