Skip to content

Instantly share code, notes, and snippets.

@Professor-plum
Last active April 14, 2021 17:02
Show Gist options
  • Save Professor-plum/e6094854a54310b9d855fbaaaeb07d06 to your computer and use it in GitHub Desktop.
Save Professor-plum/e6094854a54310b9d855fbaaaeb07d06 to your computer and use it in GitHub Desktop.
import ssl
import urllib.request
import base64
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
def lambda_handler(event, context):
url = 'https://x.x.x.x/aws/gateway/'
data=None
headers={}
if event['body']:
data = base64.b64decode(event['body'])
if event['headers']:
headers=event['headers']
req = urllib.request.Request(url, data, headers)
x = urllib.request.urlopen(req, context=ctx)
return {
"isBase64Encoded": True,
"statusCode": 200,
"headers": {"Content-Type": "application/octet-stream"},
"body": base64.b64encode(x.read()).decode('utf-8')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment