I have created a simple Lambda function to trigger upon creation of an object in S3 bucket, but it does not always trigger...
The function triggers and generates a log in CloudWatch when I upload a file to the bucket. However, when I upload the same or a different file about a minute later to the same bucket, the function does not trigger again.
If I re-save the function and upload a file to the bucket again, the function triggers again. If I upload the file again a minute or so later, the function does not trigger.
If I actually wait for about 30 mins (not just a min or two) and upload a file again, the function triggers without re-saving.
Below is the function code, Python 3.7. Why it does not trigger any time I upload a file to the bucket?
import json
print("This is a test")
def lambda_handler(event, context):
# Setting variables to equal values from the event object passed in.
bucket = event['Records'][0]['s3']['bucket']['name']
region = event['Records'][0]['awsRegion']
object = event['Records'][0]['s3']['object']['key']
user = event['Records'][0]['userIdentity']['principalId']
print("Bucket: " + bucket)
print("Region: " + region)
print("User is " + user)
return(object)
Thank you :)