title: module initialization error name 'event' is not defined
body: <p>I am trying to copy file from one bucket to another through AWS Lamda Function. My AWS S3 Trigger Setting 
    <a href="https://i.stack.imgur.com/5xl7H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5xl7H.png" alt="enter image description here"></a>
  Here is the code ---></p>
  
  <pre><code>from __future__ import print_function
  
      import boto3
      import json
      import time
      import urllib
  
      print("loadig function")
      s3 = boto3.client('s3')
  
      def lambda_handler(event, context):
          source_bucket = event['Records'][0]['s3']['bucket']['name']
  
  
      key = urllib.unquote_plus(event['Records'][0]['s3']['object']['key'])
      target_bucket = 'destinationstage'
      copy_source = {'Bucket': source_bucket, 'Key': key}
      try:
          print("waiting for the file persist in the source bucket")
          waiter = s3.get_waiter('object_exists')
          waiter.wait(Bucket=source_bucket, key=key)
          print(
              "copying the object from the source s3 bucket to destination s3 bucket"
          )
          s3.copy_object(Bucket=target_bucket, Key=key, CopySource=copy_source)
  
      except Exception as e:
          print(e)
          print(
              "Error getting object {} from bucket {}. Make sure tehy exists in the bucket"
          )
          raise e
  </code></pre>
  
  <p>Here is the error message I keep receiving ---> </p>
  
  <pre><code>Request ID:
  "628ad4ad-3355-492f-8daf-019a6b9c655c"
  
  Function Logs:
  START RequestId: 628ad4ad-3355-492f-8daf-019a6b9c655c Version: $LATEST
  module initialization error: name 'event' is not defined
  
  END RequestId: 628ad4ad-3355-492f-8daf-019a6b9c655c
  REPORT RequestId: 628ad4ad-3355-492f-8daf-019a6b9c655c  Duration: 598.71 ms Billed Duration: 600 ms Memory Size: 128 MB Max Memory Used: 67 MB  Init Duration: 343.97 ms    
  module initialization error
  name 'event' is not defined
  </code></pre>