Skip to content

Instantly share code, notes, and snippets.

@zaireali649
Created April 13, 2022 19:18
Show Gist options
  • Save zaireali649/bf599dd416ce04b2c79d565261771665 to your computer and use it in GitHub Desktop.
Save zaireali649/bf599dd416ce04b2c79d565261771665 to your computer and use it in GitHub Desktop.
Create a Sample Lambda Handler Python Zip
### Create Hello Lambda .py ###
lambda_code = '''
import json
def lambda_handler(event, context):
# TODO implement
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
'''
f = open("lambda_function.py", "w")
f.write(lambda_code)
f.close()
### Create handler .zip ###
from zipfile import ZipFile
fZip = ZipFile('lambda-handler.zip', 'w')
fZip.write('lambda_function.py')
fZip.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment