-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda.py
More file actions
38 lines (32 loc) · 990 Bytes
/
lambda.py
File metadata and controls
38 lines (32 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import json
import urllib3
import warnings
from botocore.vendored import requests
warnings.filterwarnings('ignore', message='Unverified HTTPS request')
def lambda_handler(event, context):
url = "<internal_server_url>"
if event.get('httpMethod'):
http_method = event['httpMethod']
headers = ''
if event.get('headers'):
headers = event['headers']
if event.get('path'):
path = event['path']
body = ''
if event.get('body'):
body = event['body']
try:
response = requests.post(url+path, data=body, verify=False)
r = {
"isBase64Encoded": False,
"statusCode": response.status_code,
"body": json.dumps(response, default=str)
}
except:
print('Connection failed.')
r = {
"isBase64Encoded": False,
"statusCode": response.status_code,
"body": "Connection failed."
}
return r