title: AWS SQS Triggering Python Lambda Function
body: <p>The lambda function is receiving following message from SQS</p>
  <pre class="lang-json prettyprint-override"><code>&quot;Records&quot;: [
      {
          &quot;messageId&quot;: &quot;a91c1641-fb7e-4ce5-88ad-2dd180aaada6&quot;,
          &quot;receiptHandle&quot;: &quot;AQEBngcKiVX9S0IjX6SfCm5VAtaDbSxznYLDMMoN2J5pq+uzVLdyzsaBVwXVjOE94dBnzAqkbI2II8RvfIfEeQCwp/8MxV5OLJXEQiBhpm2QwCXlUy+1ludjUbKRXT6pBux0eqjuVDk4I/vQ59m3D+ut2mafo2wgEZtUqT28P5DVgpeCgwFmuHcSRoc/vjcj/5rBDSJ6Mk4T+XTnnPMkZXOY0Nl9+XWzXJe3eX+DJC7vn6Vi6wEMk84nhbjn+CdL/TpHFtA6qCFE03XEJnRQeZCf69sqbpGq+ecIKI+bxb5DMDOTIin+ugb1oqpvfhySkB9nWodYOv+P6ANeLJSm4kBRvsSriDcP9uO/whyQGUMZC1v0Kx0CFVqtVmg2fIoj5R8k3f7QU9zpTKrJO5Bn/K6BwA==&quot;,
          &quot;body&quot;: &quot;[\n    {\n        \&quot;year\&quot;: 2013,\n        \&quot;title\&quot;: \&quot;Rush\&quot;,\n        \&quot;info\&quot;: {\n            \&quot;directors\&quot;: [\&quot;Ron Howard\&quot;],\n            \&quot;release_date\&quot;: \&quot;2013-09-02T00:00:00Z\&quot;,\n            \&quot;rating\&quot;: 8.3,\n            \&quot;genres\&quot;: [\n                \&quot;Action\&quot;,\n                \&quot;Biography\&quot;,\n                \&quot;Drama\&quot;,\n                \&quot;Sport\&quot;\n            ],\n            \&quot;image_url\&quot;: \&quot;http://ia.media-imdb.com/images/M/MV5BMTQyMDE0MTY0OV5BMl5BanBnXkFtZTcwMjI2OTI0OQ@@._V1_SX400_.jpg\&quot;,\n            \&quot;plot\&quot;: \&quot;A re-creation of the merciless 1970s rivalry between Formula One rivals James Hunt and Niki Lauda.\&quot;,\n            \&quot;rank\&quot;: 2,\n            \&quot;running_time_secs\&quot;: 7380,\n            \&quot;actors\&quot;: [\n                \&quot;Daniel Bruhl\&quot;,\n                \&quot;Chris Hemsworth\&quot;,\n                \&quot;Olivia Wilde\&quot;\n            ]\n        }\n    }\n]&quot;,
          &quot;attributes&quot;: {
              &quot;ApproximateReceiveCount&quot;: &quot;1&quot;,
              &quot;SentTimestamp&quot;: &quot;1604156768953&quot;,
              &quot;SenderId&quot;: &quot;983336180496&quot;,
              &quot;ApproximateFirstReceiveTimestamp&quot;: &quot;1604156768958&quot;
          },
          &quot;messageAttributes&quot;: {},
          &quot;md5OfBody&quot;: &quot;3d249c6c5e1b6cffc0f7af7101f3ea40&quot;,
          &quot;eventSource&quot;: &quot;aws:sqs&quot;,
          &quot;eventSourceARN&quot;: &quot;arn:aws:sqs:us-east-1:983336180496:Parse-SQS-Msg&quot;,
          &quot;awsRegion&quot;: &quot;us-east-1&quot;
      }
  ]
  </code></pre>
  <p>Now in the body section I want to extract details like &quot;Year&quot;, &quot;Title&quot; and &quot;Rating&quot;. How can I extract these details in different variables so that I can write logic on these accordingly? The details I want to extract are Year, Title, genres and rating:</p>
  <pre class="lang-json prettyprint-override"><code>&quot;body&quot;: &quot;[
      {
          &quot;year&quot;: 2013,
          &quot;title&quot;: &quot;Rush&quot;,
          &quot;info&quot;: {
              &quot;directors&quot;: [&quot;Ron Howard&quot;],
              &quot;release_date&quot;: &quot;2013-09-02T00:00:00Z&quot;,
              &quot;rating&quot;: 8.3,
              &quot;genres&quot;: [
                  &quot;Action&quot;,
                  &quot;Biography&quot;,
                  &quot;Drama&quot;,
                  &quot;Sport&quot;
              ],
              &quot;image_url&quot;: &quot;http://ia.media-imdb.com/images/M/MV5BMTQyMDE0MTY0OV5BMl5BanBnXkFtZTcwMjI2OTI0OQ@@._V1_SX400_.jpg&quot;,
              &quot;plot&quot;: &quot;A re-creation of the merciless 1970s rivalry between Formula One rivals James Hunt and Niki Lauda.&quot;,
              &quot;rank&quot;: 2,
              &quot;running_time_secs&quot;: 7380,
              &quot;actors&quot;: [
                  &quot;Daniel Bruhl&quot;,
                  &quot;Chris Hemsworth&quot;,
                  &quot;Olivia Wilde&quot;
              ]
          }
      }
  ]
  </code></pre>
  <p>The code snippet is below:</p>
  <pre class="lang-py prettyprint-override"><code>    from __future__ import print_function
      from pprint import pprint
      from botocore.vendored import requests
      import boto3
      import json
      
      dynamodb = boto3.resource('dynamodb')
      
      def lambda_handler(event, context):
          print(&quot;Received event: &quot; + json.dumps(event, indent=2))
          for record in event['Records']:
             print (&quot;test&quot;)
             year_e = record['body'][0]
             print(year_e)
             payload=record[&quot;body&quot;]
             print(str(payload))
  </code></pre>
  <p>I tried several permutations and combinations from web but nothing helped. I am very new to Python so quick help is appreciated.</p>