Skip to content

Commit a23686e

Browse files
committed
update statmentId for the cloudwatch integrations
1 parent b9cffa9 commit a23686e

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Changelog
2+
3+
## v1.0.11 / 2024-07-30
4+
### 🧰 Bug fixes 🧰
5+
- fix bug when trying to deploy CloudWatch integration with log group, with a name longer than 70 letters.
6+
27
## v1.0.10 / 2024-07-23
38
### 💡 Enhancements 💡
49
- Improved tamplate.yaml

custom-resource/index.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,11 @@ def create(self):
409409

410410
if LambdaPremissionPrefix and LambdaPremissionPrefix != [""]:
411411
for prefix in LambdaPremissionPrefix:
412+
replaced_prefix = self.check_statmentid_length(prefix)
412413
try:
413414
self.aws_lambda.add_permission(
414415
FunctionName=lambda_arn,
415-
StatementId=f'allow-trigger-from-{prefix.replace("/", "-")}-log-groups',
416+
StatementId=f'allow-trigger-from-{replaced_prefix.replace("/", "-")}-log-groups',
416417
Action='lambda:InvokeFunction',
417418
Principal='logs.amazonaws.com',
418419
SourceArn=f'arn:aws:logs:{region}:{account_id}:log-group:{prefix}*:*',
@@ -427,9 +428,10 @@ def create(self):
427428
)
428429
if not LambdaPremissionPrefix or LambdaPremissionPrefix == [""]:
429430
if not response.get("subscriptionFilters") or response.get("subscriptionFilters")[0].get("destinationArn") != lambda_arn:
431+
replaced_prefix = self.check_statmentid_length(log_group)
430432
response = self.aws_lambda.add_permission(
431433
FunctionName=lambda_arn,
432-
StatementId=f'allow-trigger-from-{log_group.replace("/", "-")}',
434+
StatementId=f'allow-trigger-from-{replaced_prefix.replace("/", "-")}',
433435
Action='lambda:InvokeFunction',
434436
Principal='logs.amazonaws.com',
435437
SourceArn=f'arn:aws:logs:{region}:{account_id}:log-group:{log_group}:*',
@@ -442,6 +444,15 @@ def create(self):
442444
logGroupName=log_group
443445
)
444446

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+
445456
@handle_exceptions
446457
def update(self):
447458
err = self.delete()
@@ -466,9 +477,10 @@ def delete(self):
466477
logGroupName=log_group
467478
)
468479
if not LambdaPremissionPrefix:
480+
replaced_prefix = self.check_statmentid_length(log_group)
469481
response = self.aws_lambda.remove_permission(
470482
FunctionName=lambda_arn,
471-
StatementId=f'allow-trigger-from-{log_group.replace("/", "-")}'
483+
StatementId=f'allow-trigger-from-{replaced_prefix.replace("/", "-")}'
472484
)
473485

474486
def handle(self):

template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Metadata:
2525
- kinesis
2626
- cloudfront
2727
HomePageUrl: https://coralogix.com
28-
SemanticVersion: 1.0.10
28+
SemanticVersion: 1.0.11
2929
SourceCodeUrl: https://github.com/coralogix/coralogix-aws-shipper
3030

3131
AWS::CloudFormation::Interface:

0 commit comments

Comments
 (0)