Skip to content

Commit

Permalink
Merge pull request #135 from SumoLogic/hpal_nodejs_migration
Browse files Browse the repository at this point in the history
Migration to New Runtimes
  • Loading branch information
SumoSourabh authored Apr 22, 2021
2 parents 8177515 + 3266877 commit 77040d4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ python:
- '2.7'
jobs:
include:
- stage: Node 10
node_js: '10.17'
env: FUNCTION_DIR=cloudwatchlogs-with-dlq TEST_DIR=cloudwatchlogs-with-dlq TEST_FILE=test_cwl_lambda.py NODE_VERSION="10.x"
- stage: Node 14
node_js: '14'
env: FUNCTION_DIR=cloudwatchlogs-with-dlq TEST_DIR=cloudwatchlogs-with-dlq TEST_FILE=test_cwl_lambda.py NODE_VERSION="14.x"
- stage: Node 12
node_js: '12'
env: FUNCTION_DIR=cloudwatchlogs-with-dlq TEST_DIR=cloudwatchlogs-with-dlq TEST_FILE=test_cwl_lambda.py NODE_VERSION="12.x"
- stage: Node 10
node_js: '10.17'
env: FUNCTION_DIR=loggroup-lambda-connector TEST_DIR=loggroup-lambda-connector/test TEST_FILE=test_loggroup_lambda_connector.py NODE_VERSION="10.x"
Expand Down
4 changes: 2 additions & 2 deletions cloudwatchlogs-with-dlq/DLQLambdaCloudFormation.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
}
},
"Handler": "cloudwatchlogs_lambda.handler",
"Runtime": "nodejs10.x",
"Runtime": "nodejs14.x",
"MemorySize": 128,
"Environment": {
"Variables": {
Expand Down Expand Up @@ -286,7 +286,7 @@
]
}
},
"Runtime": "nodejs10.x",
"Runtime": "nodejs14.x",
"MemorySize": 128,
"Environment": {
"Variables": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
}
},
"Handler": "cloudwatchlogs_lambda.handler",
"Runtime": "nodejs10.x",
"Runtime": "nodejs14.x",
"MemorySize": 128,
"Environment": {
"Variables": {
Expand Down Expand Up @@ -327,7 +327,7 @@
]
}
},
"Runtime": "nodejs10.x",
"Runtime": "nodejs14.x",
"MemorySize": 128,
"Environment": {
"Variables": {
Expand Down
6 changes: 5 additions & 1 deletion cloudwatchlogs-with-dlq/test_cwl_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,14 @@ def prod_deploy():
global BUCKET_PREFIX
BUCKET_PREFIX = 'appdevzipfiles'
upload_code_in_multiple_regions()
print("Uploading template file in S3")
s3 = boto3.client('s3', "us-east-1")
filename = 'DLQLambdaCloudFormation.json'
print("Uploading template file: %s in S3" % filename)
bucket_name = "appdev-cloudformation-templates"
s3.upload_file(filename, bucket_name, filename,
ExtraArgs={'ACL': 'public-read'})
filename = 'DLQLambdaCloudFormationWithSecuredEndpoint.json'
print("Uploading template file: %s in S3" % filename)
s3.upload_file(filename, bucket_name, filename,
ExtraArgs={'ACL': 'public-read'})
print("Deployment Successfull: ALL files copied to Sumocontent")
Expand Down
10 changes: 5 additions & 5 deletions inspector/python/inspector.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import json
import httplib
import http.client
import base64,zlib
import urlparse
import urllib.parse
import boto3
import datetime
import logging
Expand All @@ -19,7 +19,7 @@
##################################################################
# Main Code #
##################################################################
up = urlparse.urlparse(sumoEndpoint)
up = urllib.parse.urlparse(sumoEndpoint)
options = { 'hostname': up.hostname,
'path': up.path,
'method': 'POST'
Expand All @@ -33,7 +33,7 @@

# main function to send data to a Sumo HTTP source
def sendSumo(msg, toCompress = False):
conn = httplib.HTTPSConnection(options['hostname'])
conn = http.client.HTTPSConnection(options['hostname'])
if (toCompress):
headers = {"Content-Encoding": "gzip"}
finalData = compress(msg)
Expand All @@ -50,7 +50,7 @@ def sendSumo(msg, toCompress = False):
# Simple function to compress data
def compress(data, compresslevel=9):
compress = zlib.compressobj(compresslevel, zlib.DEFLATED, 16 + zlib.MAX_WBITS, zlib.DEF_MEM_LEVEL, 0)
compressedData = compress.compress(data)
compressedData = compress.compress(data.encode())
compressedData += compress.flush()
return compressedData

Expand Down

0 comments on commit 77040d4

Please sign in to comment.