-
-
Notifications
You must be signed in to change notification settings - Fork 25
Archive Cloudwatch Log Groups by Tag and update Python to 3.9 #11
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ Metadata: | |
Parameters: | ||
- SubscribeSchedule | ||
- LogGroupNamePrefix | ||
- LogGroupTagName | ||
ParameterLabels: | ||
AllowedAccounts: | ||
default: Allowed Accounts | ||
|
@@ -112,6 +113,8 @@ Metadata: | |
default: Export Format | ||
LogGroupNamePrefix: | ||
default: Required Log Group Name Prefix | ||
LogGroupTagName: | ||
default: Archive log groups by Tag | ||
ProcessorBufferIntervalHint: | ||
default: Processing Lambda Buffer Timeout | ||
ProcessorBufferSizeHint: | ||
|
@@ -199,6 +202,10 @@ Parameters: | |
Description: Prefix to match against log group that should be exported (leave | ||
empty to export all log groups) | ||
Type: String | ||
LogGroupTagName: | ||
Default: 'archive_log_group_to_s3' | ||
Description: Adding this tag to a log group will force the scheduled LogSubscriberFunction to archive tagged log group (leave empty to not filter by tags) | ||
Type: String | ||
ProcessorBufferIntervalHint: | ||
Default: '60' | ||
Description: Processing Lambda buffer timeout (in seconds, only in raw format | ||
|
@@ -582,7 +589,7 @@ Resources: | |
Fn::GetAtt: | ||
- LogProcessorRole | ||
- Arn | ||
Runtime: python3.6 | ||
Runtime: python3.9 | ||
Timeout: 300 | ||
Type: AWS::Lambda::Function | ||
LogProcessorRole: | ||
|
@@ -663,7 +670,16 @@ Resources: | |
|
||
def subscribe_all(): | ||
for log_group_name in matched_log_groups("${LogGroupNamePrefix}"): | ||
subscribe(log_group_name) | ||
if not "${LogGroupTagName}": | ||
subscribe(log_group_name) | ||
else: | ||
tags_in_group_response = logs_client.list_tags_log_group( | ||
logGroupName = log_group_name | ||
) | ||
print("tags_in_group_response", tags_in_group_response) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need this print? |
||
for tag in tags_in_group_response["tags"]: | ||
if tag == "${LogGroupTagName}": | ||
subscribe(log_group_name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a |
||
|
||
|
||
def unsubscribe_all(): | ||
|
@@ -737,7 +753,7 @@ Resources: | |
Fn::GetAtt: | ||
- LogSubscriberRole | ||
- Arn | ||
Runtime: python3.6 | ||
Runtime: python3.9 | ||
Timeout: 300 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's increase the timeout since we're doing much more. |
||
Type: AWS::Lambda::Function | ||
LogSubscriberPermission: | ||
|
@@ -774,6 +790,7 @@ Resources: | |
- logs:DeleteSubscriptionFilter | ||
- logs:DescribeLogGroups | ||
- logs:PutSubscriptionFilter | ||
- logs:ListTagsLogGroup | ||
Effect: Allow | ||
Resource: '*' | ||
Sid: Logs | ||
|
@@ -810,4 +827,4 @@ Resources: | |
- LogSubscriberFunction | ||
- Arn | ||
Type: Custom::Subscriber | ||
Transform: AWS::Serverless-2016-10-31 | ||
Transform: AWS::Serverless-2016-10-31 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the default should be empty to keep backwards compatibility.