title: AWS Lambda Function Triggers on S3 Event, But only Once in About 30 Mins
body: <p>I have created a simple Lambda function to trigger upon creation of an object in S3 bucket, but it does not always trigger... </p>
  
  <ol>
  <li><p>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. </p></li>
  <li><p>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.</p></li>
  <li><p>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.</p></li>
  </ol>
  
  <p>Below is the function code, Python 3.7. Why it does not trigger any time I upload a file to the bucket?</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Thank you :)</p>