Skip to content

Instantly share code, notes, and snippets.

@mbklein
Created April 5, 2018 18:59
Show Gist options
  • Save mbklein/ef433ba3830cced6a3204b9fa4d7039e to your computer and use it in GitHub Desktop.
Save mbklein/ef433ba3830cced6a3204b9fa4d7039e to your computer and use it in GitHub Desktop.
Lambda for pushing URL to S3
import boto3
import botocore.vendored.requests.packages.urllib3 as urllib3
def lambda_handler(event, context):
url=event.url
bucket = event.s3_bucket_name
key = event.s3_key
s3=boto3.client('s3')
http=urllib3.PoolManager()
s3.upload_fileobj(http.request('GET', url,preload_content=False), bucket, key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment