Instantly share code, notes, and snippets.

Embed
What would you like to do?
Downloads the lambda runtime directory
import os
def download_code(event, context):
"""
Download the runtime environment of a lambda to a given s3 bucket.
"""
os.system("/bin/tar -zcvf /tmp/code.tar.gz /var/runtime/")
with open("/tmp/code.tar.gz", "rb") as code:
s3.upload_fileobj(code, event['bucket_name'], 'code.tar.gz')
@kqia040

This comment has been minimized.

kqia040 commented May 15, 2018

Might want to add
import boto3
s3 = boto3.client('s3')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment