Created
August 25, 2018 02:15
-
-
Save marcieltorres/f73578b503d0726da746fdd6993147da to your computer and use it in GitHub Desktop.
AWS Lambda function to trigger objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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