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

[AWSX][logs forwarder] Properly handle Transit gateway log source #844

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion aws/logs_monitoring/steps/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, string, event_source):
REDSHIFT = ("_redshift_", AwsEventSource.REDSHIFT)
# e.g. AWSLogs/123456779121/vpcdnsquerylogs/vpc-********/2021/05/11/vpc-********_vpcdnsquerylogs_********_20210511T0910Z_71584702.log.gz
ROUTE53 = ("vpcdnsquerylogs", AwsEventSource.ROUTE53)
TRANSITAGATEWAY = ("transit-gateway", AwsEventSource.TRANSITGATEWAY)
TRANSITGATEWAY = ("transit-gateway", AwsEventSource.TRANSITGATEWAY)
VERIFIED_ACCESS = ("verified-access", AwsEventSource.VERIFIED_ACCESS)
# e.g. AWSLogs/123456779121/vpcflowlogs/us-east-1/2020/10/02/123456779121_vpcflowlogs_us-east-1_fl-xxxxx.log.gz
VPC = ("vpcflowlogs", AwsEventSource.VPC)
Expand Down
4 changes: 2 additions & 2 deletions aws/logs_monitoring/steps/handlers/s3_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def _extract_event(self, event):

def _set_source(self, event):
self.data_store.source = parse_event_source(event, self.data_store.key)
if str(AwsS3EventSourceKeyword.TRANSITAGATEWAY) in self.data_store.bucket:
self.data_store.source = AwsEventSource.TRANSITGATEWAY
if str(AwsS3EventSourceKeyword.TRANSITGATEWAY) in self.data_store.bucket:
self.data_store.source = str(AwsEventSource.TRANSITGATEWAY)
self.metadata[DD_SOURCE] = self.data_store.source

def _set_host(self):
Expand Down
20 changes: 20 additions & 0 deletions aws/logs_monitoring/tests/test_s3_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,26 @@ def test_set_source_cloudfront(self):
"cloudfront",
)

def test_set_source_transit_gateway(self):
self.s3_handler.data_store.key = "AWSLogs/1234566312/vpcflowlogs/us-east-1/2024/08/09/11/123455660991_vpcflowlogs_us-east-1_fl-01fb37"
self.s3_handler.data_store.bucket = "my-bucket-transit-gateway"
self.s3_handler._set_source(
{
"Records": [
{
"s3": {
"bucket": {"name": "my-bucket-transit-gateway"},
"object": {"key": self.s3_handler.data_store.key},
}
}
]
}
)
self.assertEqual(
self.s3_handler.data_store.source,
"transitgateway",
)


if __name__ == "__main__":
unittest.main()
Loading