Skip to content

Instantly share code, notes, and snippets.

@tavin
Created October 25, 2018 11:04
Show Gist options
  • Save tavin/06bafc563dc7b82baa7c133b3ae48085 to your computer and use it in GitHub Desktop.
Save tavin/06bafc563dc7b82baa7c133b3ae48085 to your computer and use it in GitHub Desktop.
from base64 import b64encode
from subprocess import check_call
from subprocess import check_output
from tempfile import mkdtemp
def lambda_handler(_event, _context):
tmp = mkdtemp(dir='/tmp')
check_call(['pip', 'install', 'psycopg2', '--target', tmp])
tar = check_output(['tar', '-C', tmp, '-cz', '.'])
return str(b64encode(tar), 'ascii')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment