Skip to content

Instantly share code, notes, and snippets.

@galbash
Created April 15, 2018 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save galbash/405903a077fc500268905f3a1117cacb to your computer and use it in GitHub Desktop.
Save galbash/405903a077fc500268905f3a1117cacb to your computer and use it in GitHub Desktop.
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
Copy link

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