title: While retrieving the bucket name from aws lambda event I am getting this error. ( "errorMessage": "'Records'" "errorType": "KeyError")
body: <p>The command I'm trying to run is</p>
  <pre class="lang-py prettyprint-override"><code>def lambda_handler(event, context):
      print(event)
      
      #retrieve bucket name and file_key from the S3 event
      bucket_name = event['Records'][0]['s3']['bucket']['name']
      file_key = event['query']['Records'][0]['s3']['object']['key']
  </code></pre>
  <p>The result:</p>
  <pre class="lang-json prettyprint-override"><code>{'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
  </code></pre>
  <p>The error:</p>
  <pre><code>[ERROR] KeyError: 'Records'
  Traceback (most recent call last):
    File &quot;/var/task/lambda_function.py&quot;, line 12, in lambda_handler
      bucket_name = event['Records'][0]['s3']['bucket']['name']
  END RequestId: 29150087-77bd-49db-a88b-61eb8a1645fd
  </code></pre>