Q:

DynamoDB insert (put) item - return the item created?

In my Python script I insert a record (item) into DynamoDB table, but I realized the response from AWS doesn't include the actual item inserted:
{'ResponseMetadata': {'HTTPHeaders': {'connection': 'keep-alive',
   'content-length': '2',
   'content-type': 'application/x-amz-json-1.0',
   'date': 'Fri, 27 Jan 2017 23:31:22 GMT',
   'server': 'Server',
   'x-amz-crc32': '234324243',
   'x-amzn-requestid': 'xxxxxxxxxx'},
  'HTTPStatusCode': 200,
  'RequestId': 'xxxxxxxxxx',
  'RetryAttempts': 0}}

This is unfortunate as I have logic like:
if not user.exists():
    user = create_user()
else:
    user = get_user()

user.do_something()

and I'd rather not do another round trip just to get the user object I just inserted. 
I can, of course, mock the object since using boto3 in Python the user object is just a dictionary-like thing, but it's nice to be able to just use a single representation. Also it seems like the put_item call 
r = user_table.put_item(Item={'user_id': uid, 'info' : { ... }})

should be able to return the put'd item? Or some other endpoint can?
Thanks for any insight!

A:

You need to set the property ReturnValues='ALL_NEW' on your put_item request to get the item back in the response. As documented here
Edit: The documentation is wrong, ALL_NEW isn't accepted for put_item. Since you have the exact item in memory as the parameter you passed to put_item, you really don't need it to be returned.

