Skip to content
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 cloudwatchevents/guardduty/deploy.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ else
AWS_REGION="us-east-2"
fi

version="1.0.4"
version="1.0.5"

echo "Creating package.yaml"
sam package --template-file template.yaml --s3-bucket $SAM_S3_BUCKET --output-template-file packaged.yaml --s3-prefix "GuardDuty/v"$version --region $AWS_REGION --profile $AWS_PROFILE
Expand Down
12 changes: 6 additions & 6 deletions cloudwatchevents/guardduty/packaged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Metadata:
- cloudwatchevents
- guardduty
Name: sumologic-guardduty-events-processor
LicenseUrl: s3://appdevstore/GuardDuty/v1.0.4/6092dd6c323e33634657102f570628e0
ReadmeUrl: s3://appdevstore/GuardDuty/v1.0.4/9d217c45b3ababadef584aee27d4d607
SemanticVersion: 1.0.4
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/tree/master/cloudwatchevents/guardduty
LicenseUrl: s3://appdevstore/GuardDuty/v1.0.5/6092dd6c323e33634657102f570628e0
ReadmeUrl: s3://appdevstore/GuardDuty/v1.0.5/9d217c45b3ababadef584aee27d4d607
SemanticVersion: 1.0.5
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/tree/main/cloudwatchevents/guardduty
SpdxLicenseId: Apache-2.0
Parameters:
SumoEndpointUrl:
Expand All @@ -35,9 +35,9 @@ Resources:
CloudWatchEventFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://appdevstore/GuardDuty/v1.0.4/22b7b226ca9ec3b9dbb28b94c0e5f824
CodeUri: s3://appdevstore/GuardDuty/v1.0.5/22b7b226ca9ec3b9dbb28b94c0e5f824
Handler: cloudwatchevents.handler
Runtime: nodejs18.x
Runtime: nodejs20.x
Environment:
Variables:
SUMO_ENDPOINT:
Expand Down
6 changes: 3 additions & 3 deletions cloudwatchevents/guardduty/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Metadata:
Name: sumologic-guardduty-events-processor
LicenseUrl: ../LICENSE
ReadmeUrl: ./README.md
SemanticVersion: 1.0.4
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/tree/master/cloudwatchevents/guardduty
SemanticVersion: 1.0.5
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/tree/main/cloudwatchevents/guardduty
SpdxLicenseId: Apache-2.0

Parameters:
Expand All @@ -38,7 +38,7 @@ Resources:
Properties:
CodeUri: ../src/
Handler: cloudwatchevents.handler
Runtime: nodejs18.x
Runtime: nodejs20.x
Environment:
Variables:
SUMO_ENDPOINT: !Ref SumoEndpointUrl
Expand Down
2 changes: 1 addition & 1 deletion cloudwatchevents/guarddutybenchmark/deploy.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ else
AWS_REGION="us-east-2"
fi

version="1.0.13"
version="1.0.14"

echo "Creating package.yaml"
sam package --template-file template_v2.yaml --s3-bucket $SAM_S3_BUCKET --output-template-file packaged.yaml --s3-prefix "guarddutybenchmark/v"$version --region $AWS_REGION --profile $AWS_PROFILE
Expand Down
15 changes: 8 additions & 7 deletions cloudwatchevents/guarddutybenchmark/packaged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Transform: AWS::Serverless-2016-10-31
Description: 'This function is invoked by AWS CloudWatch events in response to state
change in your AWS resources which matches a event target definition. The event
payload received is then forwarded to Sumo Logic HTTP source endpoint.

'
Globals:
Function:
Expand Down Expand Up @@ -52,10 +53,10 @@ Metadata:
- benchmark
- guardduty
Name: sumologic-guardduty-benchmark
LicenseUrl: s3://appdevstore/guarddutybenchmark/v1.0.13/6092dd6c323e33634657102f570628e0
ReadmeUrl: s3://appdevstore/guarddutybenchmark/v1.0.13/cab012d7fb7887671b751e6f5c0d2062
SemanticVersion: 1.0.13
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/tree/master/cloudwatchevents/guarddutybenchmark
LicenseUrl: s3://appdevstore/guarddutybenchmark/v1.0.14/6092dd6c323e33634657102f570628e0
ReadmeUrl: s3://appdevstore/guarddutybenchmark/v1.0.14/cab012d7fb7887671b751e6f5c0d2062
SemanticVersion: 1.0.14
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/tree/main/cloudwatchevents/guarddutybenchmark
SpdxLicenseId: Apache-2.0
Parameters:
CollectorName:
Expand Down Expand Up @@ -95,7 +96,7 @@ Parameters:
Resources:
CloudWatchEventFunction:
Properties:
CodeUri: s3://appdevstore/guarddutybenchmark/v1.0.13/22b7b226ca9ec3b9dbb28b94c0e5f824
CodeUri: s3://appdevstore/guarddutybenchmark/v1.0.14/22b7b226ca9ec3b9dbb28b94c0e5f824
Environment:
Variables:
SUMO_ENDPOINT:
Expand All @@ -110,7 +111,7 @@ Resources:
- aws.guardduty
Type: CloudWatchEvent
Handler: cloudwatchevents.handler
Runtime: nodejs18.x
Runtime: nodejs20.x
Type: AWS::Serverless::Function
Metadata:
SamResourceId: CloudWatchEventFunction
Expand All @@ -119,7 +120,7 @@ Resources:
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:us-east-1:956882708938:applications/sumologic-app-utils
SemanticVersion: 2.0.11
SemanticVersion: 2.0.15
Metadata:
SamResourceId: SumoAppUtils
SumoHostedCollector:
Expand Down
8 changes: 4 additions & 4 deletions cloudwatchevents/guarddutybenchmark/template_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ Metadata:
Name: sumologic-guardduty-benchmark
LicenseUrl: ../LICENSE
ReadmeUrl: ./README.md
SemanticVersion: 1.0.13
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/tree/master/cloudwatchevents/guarddutybenchmark
SemanticVersion: 1.0.14
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/tree/main/cloudwatchevents/guarddutybenchmark
SpdxLicenseId: Apache-2.0

Parameters:
Expand Down Expand Up @@ -110,15 +110,15 @@ Resources:
- aws.guardduty
Type: CloudWatchEvent
Handler: cloudwatchevents.handler
Runtime: nodejs18.x
Runtime: nodejs20.x
Type: AWS::Serverless::Function

SumoAppUtils:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:us-east-1:956882708938:applications/sumologic-app-utils
SemanticVersion: 2.0.11
SemanticVersion: 2.0.15

SumoHostedCollector:
Type: Custom::Collector
Expand Down
2 changes: 1 addition & 1 deletion cloudwatchevents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"description": "AWS Lambda function to collect CloudWatch events and post them to SumoLogic.",
"main": "src/cloudwatchevents.js",
"repository": "https://github.com/SumoLogic/sumologic-aws-lambda/tree/master/cloudwatchevents",
"repository": "https://github.com/SumoLogic/sumologic-aws-lambda/tree/main/cloudwatchevents",
"author": "Himanshu Pal",
"license": "Apache-2.0",
"dependencies": {},
Expand Down
8 changes: 4 additions & 4 deletions cloudwatchlogs-with-dlq/DLQLambdaCloudFormation.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"FunctionName": { "Fn::Join": [ "-", [ "SumoCWLogsLambda", { "Fn::Select" : [ "2", {"Fn::Split" : [ "/" , { "Ref": "AWS::StackId" } ]}] } ] ] },
"Code": {
"S3Bucket": { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "bucketname"]},
"S3Key": "cloudwatchLogsDLQ/v1.2.0/cloudwatchlogs-with-dlq.zip"
"S3Key": "cloudwatchLogsDLQ/v1.3.0/cloudwatchlogs-with-dlq.zip"
},
"Role": {
"Fn::GetAtt": [
Expand All @@ -228,7 +228,7 @@
}
},
"Handler": "cloudwatchlogs_lambda.handler",
"Runtime": "nodejs18.x",
"Runtime": "nodejs20.x",
"MemorySize": 128,
"Environment": {
"Variables": {
Expand Down Expand Up @@ -272,7 +272,7 @@
"FunctionName": { "Fn::Join": [ "-", [ "SumoCWProcessDLQLambda", { "Fn::Select" : [ "2", {"Fn::Split" : [ "/" , { "Ref": "AWS::StackId" } ]}] } ] ] },
"Code": {
"S3Bucket": { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "bucketname"]},
"S3Key": "cloudwatchLogsDLQ/v1.2.0/cloudwatchlogs-with-dlq.zip"
"S3Key": "cloudwatchLogsDLQ/v1.3.0/cloudwatchlogs-with-dlq.zip"
},
"Role": {
"Fn::GetAtt": [
Expand All @@ -290,7 +290,7 @@
]
}
},
"Runtime": "nodejs18.x",
"Runtime": "nodejs20.x",
"MemorySize": 128,
"Environment": {
"Variables": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
"FunctionName": { "Fn::Join": [ "-", [ "SumoCWLogsLambda", { "Fn::Select" : [ "2", {"Fn::Split" : [ "/" , { "Ref": "AWS::StackId" } ]}] } ] ] },
"Code": {
"S3Bucket": { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "bucketname"]},
"S3Key": "cloudwatchLogsDLQ/v1.2.0/cloudwatchlogs-with-dlq.zip"
"S3Key": "cloudwatchLogsDLQ/v1.3.0/cloudwatchlogs-with-dlq.zip"
},
"Role": {
"Fn::GetAtt": [
Expand All @@ -270,7 +270,7 @@
}
},
"Handler": "cloudwatchlogs_lambda.handler",
"Runtime": "nodejs18.x",
"Runtime": "nodejs20.x",
"MemorySize": 128,
"Environment": {
"Variables": {
Expand Down Expand Up @@ -313,7 +313,7 @@
"FunctionName": { "Fn::Join": [ "-", [ "SumoCWProcessDLQLambda", { "Fn::Select" : [ "2", {"Fn::Split" : [ "/" , { "Ref": "AWS::StackId" } ]}] } ] ] },
"Code": {
"S3Bucket": { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "bucketname"]},
"S3Key": "cloudwatchLogsDLQ/v1.2.0/cloudwatchlogs-with-dlq.zip"
"S3Key": "cloudwatchLogsDLQ/v1.3.0/cloudwatchlogs-with-dlq.zip"
},
"Role": {
"Fn::GetAtt": [
Expand All @@ -331,7 +331,7 @@
]
}
},
"Runtime": "nodejs18.x",
"Runtime": "nodejs20.x",
"MemorySize": 128,
"Environment": {
"Variables": {
Expand Down
Binary file modified cloudwatchlogs-with-dlq/cloudwatchlogs-with-dlq.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions cloudwatchlogs-with-dlq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"description": "Lambda function for processing messages from CloudWatch with Dead Letter Queue Support",
"main": "DLQProcessor.js",
"dependencies": {
"jmespath": "^0.15.0",
"lodash": "^4.17.15"
"jmespath": "^0.16.0",
"lodash": "^4.17.21"
},
"devDependencies": {},
"scripts": {
"test": "node -e 'require('./test').test()'",
"build": "rm -f cloudwatchlogs-with-dlq.zip && npm install && zip -r cloudwatchlogs-with-dlq.zip DLQProcessor.js cloudwatchlogs_lambda.js vpcutils.js package.json sumo-dlq-function-utils/ node_modules/",
"prod_deploy": "python -c 'from test_cwl_lambda import prod_deploy;prod_deploy()'"
"prod_deploy": "python3 -c 'from test_cwl_lambda import prod_deploy;prod_deploy()'"
},
"author": "Himanshu Pal",
"license": "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion cloudwatchlogs-with-dlq/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests==2.31.0
requests==2.32.2
boto3==1.5.1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"files": ["./lib"],
"main": "./lib/mainindex",
"dependencies": {
"aws-sdk": "^2.160.0"
"aws-sdk": "^2.1633.0"
},
"devDependencies": {},
"author": "Himanshu Pal"
Expand Down
21 changes: 13 additions & 8 deletions cloudwatchlogs-with-dlq/test_cwl_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import datetime

BUCKET_PREFIX = "appdevstore"

VERSION = "v1.3.0"
AWS_PROFILE = "prod"

class TestLambda(unittest.TestCase):
TEMPLATE_KEYS_TO_REMOVE = ['SumoCWProcessDLQScheduleRule',
Expand All @@ -23,6 +24,7 @@ def setUp(self):
}
self.stack_name = "TestCWLStack-%s" % (
datetime.datetime.now().strftime("%d-%m-%y-%H-%M-%S"))
boto3.setup_default_session(profile_name=AWS_PROFILE)
self.cf = boto3.client('cloudformation',
self.config['AWS_REGION_NAME'])
self.template_name = 'DLQLambdaCloudFormation.json'
Expand All @@ -33,8 +35,8 @@ def setUp(self):
self.template_data = self._parse_template(self.template_name)
# replacing prod zipfile location to test zipfile location
self.template_data = self.template_data.replace("appdevzipfiles", BUCKET_PREFIX)
RUNTIME = "nodejs%s" % os.environ.get("NODE_VERSION", "10.x")
self.template_data = self.template_data.replace("nodejs10.x", RUNTIME)
RUNTIME = "nodejs%s" % os.environ.get("NODE_VERSION", "20.x")
self.template_data = self.template_data.replace("nodejs20.x", RUNTIME)

def tearDown(self):
if self.stack_exists(self.stack_name):
Expand Down Expand Up @@ -103,11 +105,12 @@ def insert_mock_logs_in_DLQ(self):
print("Inserting fake logs in DLQ")
dlq_queue_url = self._get_dlq_url()
sqs_client = boto3.client('sqs', self.config['AWS_REGION_NAME'])
mock_logs = json.load(open('cwlfixtures.json'))
with open('cwlfixtures.json', 'r', encoding='UTF-8') as file:
mock_logs = json.load(file)
for log in mock_logs:
sqs_client.send_message(QueueUrl=dlq_queue_url,
MessageBody=json.dumps(log))
sleep(15) # waiting for messages to be ingested in SQS
sleep(60) # waiting for messages to be ingested in SQS
self.initial_log_count = self._get_message_count()
print("Inserted %s Messages in %s" % (
self.initial_log_count, dlq_queue_url))
Expand Down Expand Up @@ -148,7 +151,7 @@ def check_consumed_messages_count(self):
print("Testing number of consumed messages initial: %s final: %s processed: %s" % (
self.initial_log_count, final_message_count,
self.initial_log_count - final_message_count))
self.assertGreater(self.initial_log_count, final_message_count)
self.assertEqual(self.initial_log_count, final_message_count)

def _parse_template(self, template):
with open(template) as template_fileobj:
Expand Down Expand Up @@ -241,10 +244,11 @@ def create_bucket(region):

def upload_code_in_S3(region):
filename = 'cloudwatchlogs-with-dlq.zip'
print("Uploading zip file %s in S3 %s" % (filename, region))
boto3.setup_default_session(profile_name=AWS_PROFILE)
s3 = boto3.client('s3', region)
bucket_name = get_bucket_name(region)
s3.upload_file(filename, bucket_name, filename,
print("Uploading zip file %s in S3 bucket (%s) at region (%s)" % (filename, bucket_name, region))
s3.upload_file(filename, bucket_name, f"cloudwatchLogsDLQ/{VERSION}/{filename}",
ExtraArgs={'ACL': 'public-read'})


Expand All @@ -266,6 +270,7 @@ def prod_deploy():
global BUCKET_PREFIX
BUCKET_PREFIX = 'appdevzipfiles'
upload_code_in_multiple_regions()
boto3.setup_default_session(profile_name=AWS_PROFILE)
s3 = boto3.client('s3', "us-east-1")
filename = 'DLQLambdaCloudFormation.json'
print("Uploading template file: %s in S3" % filename)
Expand Down
14 changes: 7 additions & 7 deletions loggroup-lambda-connector/sam/packaged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ Metadata:
- serverless
- loggroups
- cloudwatch
LicenseUrl: s3://appdevstore/LoggroupConnector/v1.0.9/6092dd6c323e33634657102f570628e0
LicenseUrl: s3://appdevstore/LoggroupConnector/v1.0.11/6092dd6c323e33634657102f570628e0
Name: sumologic-loggroup-connector
ReadmeUrl: s3://appdevstore/LoggroupConnector/v1.0.9/5a9a6e956be7449cbd5f8653e4475071
SemanticVersion: 1.0.9
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/loggroup-lambda-connector
ReadmeUrl: s3://appdevstore/LoggroupConnector/v1.0.11/5a9a6e956be7449cbd5f8653e4475071
SemanticVersion: 1.0.11
SourceCodeUrl: https://github.com/SumoLogic/sumologic-aws-lambda/tree/main/loggroup-lambda-connector
SpdxLicenseId: Apache-2.0
Parameters:
DestinationArnType:
Expand Down Expand Up @@ -107,9 +107,9 @@ Resources:
SumoLogGroupLambdaConnector:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://appdevstore/LoggroupConnector/v1.0.9/cce618f8c5a615a33b63966712edaf2e
CodeUri: s3://appdevstore/LoggroupConnector/v1.0.11/cce618f8c5a615a33b63966712edaf2e
Handler: loggroup-lambda-connector.handler
Runtime: nodejs18.x
Runtime: nodejs20.x
Environment:
Variables:
DESTINATION_ARN:
Expand Down Expand Up @@ -201,7 +201,7 @@ Resources:
\ console.log(responseData.Error + \":\\n\", err);\n }\n \n await response.send(event,\
\ context, responseStatus, responseData);\n};\n"
Handler: index.handler
Runtime: nodejs18.x
Runtime: nodejs20.x
Environment:
Variables:
FUNCTION_NAME:
Expand Down
3 changes: 2 additions & 1 deletion loggroup-lambda-connector/sam/sam_package.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

export AWS_PROFILE="prod"
if [ "$AWS_PROFILE" == "prod" ]
then
SAM_S3_BUCKET="appdevstore"
Expand All @@ -9,7 +10,7 @@ else
AWS_REGION="us-east-2"
fi

version="1.0.9"
version="1.0.11"

sam package --template-file template.yaml --s3-bucket $SAM_S3_BUCKET --output-template-file packaged.yaml --s3-prefix "LoggroupConnector/v$version" --region $AWS_REGION

Expand Down
Loading