title: Requesting help triggering a lambda function from DynamoDB
body: <p>I was following the guide posted here on youtube <a href="https://www.youtube.com/watch?v=jgiZ9QUYqyM" rel="nofollow noreferrer">https://www.youtube.com/watch?v=jgiZ9QUYqyM</a> and is defiantly what I want. I posted the code that I had for mine and the image of what everything looks like in my AWS.</p>
  
  <p>I have a dynamodb table and linked it to my s3 bucket with a trigger. That trigger is giving me some error message which is posted above. "Decimal('1') is not JSON serializable". Though I was testing it with the helloworld.</p>
  
  <p>This is the code :</p>
  
  <pre><code>import boto3
  import json
  import os
  s3 =  boto3.client('s3')
  ddb = boto3.resource('dynamodb')
  table = ddb.Table('test_table')
  
  
  def lambda_handler(event, context):
    response = table.scan()
    body = json.dumps(response['Items'])
    response = s3.put_object(Bucket='s3-testing',
    Key = 's3-testing.json' ,
    Body=body,
    ContentType='application/json')
  </code></pre>
  
  <p>Can someone point me in the right direction? These are the snippets I got </p>
  
  <p><a href="https://i.stack.imgur.com/I0jAn.png" rel="nofollow noreferrer">https://i.stack.imgur.com/I0jAn.png</a></p>
  
  <p><a href="https://i.stack.imgur.com/2hMc9.png" rel="nofollow noreferrer">https://i.stack.imgur.com/2hMc9.png</a></p>
  
  <p>This is the execution log: </p>
  
  <pre><code>Response:
  {
    "stackTrace": [
      [
        "/var/task/lambda_function.py",
        20,
        "lambda_handler",
        "body = json.dumps(response['Items'])"
      ],
      [
        "/usr/lib64/python2.7/json/__init__.py",
        244,
        "dumps",
        "return _default_encoder.encode(obj)"
      ],
      [
        "/usr/lib64/python2.7/json/encoder.py",
        207,
        "encode",
        "chunks = self.iterencode(o, _one_shot=True)"
      ],
      [
        "/usr/lib64/python2.7/json/encoder.py",
        270,
        "iterencode",
        "return _iterencode(o, 0)"
      ],
      [
        "/usr/lib64/python2.7/json/encoder.py",
        184,
        "default",
        "raise TypeError(repr(o) + \" is not JSON serializable\")"
      ]
    ],
    "errorType": "TypeError",
    "errorMessage": "Decimal('1') is not JSON serializable"
  }
  </code></pre>
  
  <p>Function log: </p>
  
  <pre><code>    START RequestId: 31719509-94c7-11e8-a0d4-a9b76b7b212c Version: $LATEST
  Decimal('1') is not JSON serializable: TypeError
  Traceback (most recent call last):
    File "/var/task/lambda_function.py", line 20, in lambda_handler
      body = json.dumps(response['Items'])
    File "/usr/lib64/python2.7/json/__init__.py", line 244, in dumps
      return _default_encoder.encode(obj)
    File "/usr/lib64/python2.7/json/encoder.py", line 207, in encode
      chunks = self.iterencode(o, _one_shot=True)
    File "/usr/lib64/python2.7/json/encoder.py", line 270, in iterencode
      return _iterencode(o, 0)
    File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
      raise TypeError(repr(o) + " is not JSON serializable")
  TypeError: Decimal('1') is not JSON serializable
  </code></pre>