Skip to content

Instantly share code, notes, and snippets.

@dagrz
Created June 2, 2016 13:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dagrz/4a9348e00b3f7b46bce6dbfe661bb054 to your computer and use it in GitHub Desktop.
Save dagrz/4a9348e00b3f7b46bce6dbfe661bb054 to your computer and use it in GitHub Desktop.
import json
import urllib
import boto3
s3 = boto3.client('s3')
def lambda_handler(event, context):
bucket = event['Records'][0]['s3']['bucket']['name']
key = urllib.unquote_plus(event['Records'][0]['s3']['object']['key']).decode('utf8')
try:
response = s3.delete_object(Bucket=bucket, Key=key)
except Exception as e:
print(e)
raise e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment