Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcieltorres/f73578b503d0726da746fdd6993147da to your computer and use it in GitHub Desktop.
Save marcieltorres/f73578b503d0726da746fdd6993147da to your computer and use it in GitHub Desktop.
AWS Lambda function to trigger objects
import boto3
import re
s3 = boto3.client('s3')
def lambda_handler(event, context):
if 'Records' in event:
bucket_object = event['Records'][0]['s3']['bucket']['name']
key_object = event['Records'][0]['s3']['object']['key']
content_object = s3GetObjectContent(bucket_object, key_object)
# TODO implement
return ''
def s3GetObjectContent(bucket, key):
return s3.get_object(Bucket=bucket,Key=key)['Body'].read()
def s3PutObject(bucket, key, content):
return s3.put_object(Bucket=bucket,Key=key,Body=content)
def s3DeleteObject(bucket, key):
return s3.delete_object(Bucket=bucket,Key=key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment