Skip to content

Instantly share code, notes, and snippets.

@tavin
Created October 25, 2018 11:04
Show Gist options
  • Select an option

  • Save tavin/06bafc563dc7b82baa7c133b3ae48085 to your computer and use it in GitHub Desktop.

Select an option

Save tavin/06bafc563dc7b82baa7c133b3ae48085 to your computer and use it in GitHub Desktop.

Revisions

  1. tavin created this gist Oct 25, 2018.
    11 changes: 11 additions & 0 deletions lambda+pip+tar.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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')