Skip to content

Commit 77040d4

Browse files
authored
Merge pull request #135 from SumoLogic/hpal_nodejs_migration
Migration to New Runtimes
2 parents 8177515 + 3266877 commit 77040d4

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ python:
55
- '2.7'
66
jobs:
77
include:
8-
- stage: Node 10
9-
node_js: '10.17'
10-
env: FUNCTION_DIR=cloudwatchlogs-with-dlq TEST_DIR=cloudwatchlogs-with-dlq TEST_FILE=test_cwl_lambda.py NODE_VERSION="10.x"
8+
- stage: Node 14
9+
node_js: '14'
10+
env: FUNCTION_DIR=cloudwatchlogs-with-dlq TEST_DIR=cloudwatchlogs-with-dlq TEST_FILE=test_cwl_lambda.py NODE_VERSION="14.x"
11+
- stage: Node 12
12+
node_js: '12'
13+
env: FUNCTION_DIR=cloudwatchlogs-with-dlq TEST_DIR=cloudwatchlogs-with-dlq TEST_FILE=test_cwl_lambda.py NODE_VERSION="12.x"
1114
- stage: Node 10
1215
node_js: '10.17'
1316
env: FUNCTION_DIR=loggroup-lambda-connector TEST_DIR=loggroup-lambda-connector/test TEST_FILE=test_loggroup_lambda_connector.py NODE_VERSION="10.x"

cloudwatchlogs-with-dlq/DLQLambdaCloudFormation.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224
}
225225
},
226226
"Handler": "cloudwatchlogs_lambda.handler",
227-
"Runtime": "nodejs10.x",
227+
"Runtime": "nodejs14.x",
228228
"MemorySize": 128,
229229
"Environment": {
230230
"Variables": {
@@ -286,7 +286,7 @@
286286
]
287287
}
288288
},
289-
"Runtime": "nodejs10.x",
289+
"Runtime": "nodejs14.x",
290290
"MemorySize": 128,
291291
"Environment": {
292292
"Variables": {

cloudwatchlogs-with-dlq/DLQLambdaCloudFormationWithSecuredEndpoint.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
}
267267
},
268268
"Handler": "cloudwatchlogs_lambda.handler",
269-
"Runtime": "nodejs10.x",
269+
"Runtime": "nodejs14.x",
270270
"MemorySize": 128,
271271
"Environment": {
272272
"Variables": {
@@ -327,7 +327,7 @@
327327
]
328328
}
329329
},
330-
"Runtime": "nodejs10.x",
330+
"Runtime": "nodejs14.x",
331331
"MemorySize": 128,
332332
"Environment": {
333333
"Variables": {

cloudwatchlogs-with-dlq/test_cwl_lambda.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,14 @@ def prod_deploy():
236236
global BUCKET_PREFIX
237237
BUCKET_PREFIX = 'appdevzipfiles'
238238
upload_code_in_multiple_regions()
239-
print("Uploading template file in S3")
240239
s3 = boto3.client('s3', "us-east-1")
241240
filename = 'DLQLambdaCloudFormation.json'
241+
print("Uploading template file: %s in S3" % filename)
242242
bucket_name = "appdev-cloudformation-templates"
243+
s3.upload_file(filename, bucket_name, filename,
244+
ExtraArgs={'ACL': 'public-read'})
245+
filename = 'DLQLambdaCloudFormationWithSecuredEndpoint.json'
246+
print("Uploading template file: %s in S3" % filename)
243247
s3.upload_file(filename, bucket_name, filename,
244248
ExtraArgs={'ACL': 'public-read'})
245249
print("Deployment Successfull: ALL files copied to Sumocontent")

inspector/python/inspector.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
import json
3-
import httplib
3+
import http.client
44
import base64,zlib
5-
import urlparse
5+
import urllib.parse
66
import boto3
77
import datetime
88
import logging
@@ -19,7 +19,7 @@
1919
##################################################################
2020
# Main Code #
2121
##################################################################
22-
up = urlparse.urlparse(sumoEndpoint)
22+
up = urllib.parse.urlparse(sumoEndpoint)
2323
options = { 'hostname': up.hostname,
2424
'path': up.path,
2525
'method': 'POST'
@@ -33,7 +33,7 @@
3333

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

0 commit comments

Comments
 (0)