AWS Lambda w/ Python UUID on Dynamo DB (Concept)
<p>This is a concept question: </p>

<p>We  would like to create a unique primary key for a Dynamo DB table, while running our code on AWS Lambda.</p>

<p>If we use the python built in function uuid on AWS Lambda to create a unique key for a dynamo DB database is there any possibility that it could create a double of the key, if we had for example 5-20 billion items in our dynamodb database.</p>

<p>I know for example that the possibilities in a normal application for a double uuid key is extremely low nearly impossible. </p>

<p>As I understand every time uuid runs it makes sure it can't create a double by saving some previous value in memory. </p>

<p>However I am unsure if Lambda is just running the function below over and over with the same python console (and saving the uuid to make sure its unique) or if it is creating multiple separate console instances and running them through separately (not saving the memory of uuid).  </p>

<p>Although this is a concept question here is some sample code: </p>

<pre><code>from __future__ import print_function
from decimal import *
import boto3
import json
from locale import str
import uuid

def my_handler(event, context):
    description = event['description'] 
    spot_id = uuid.uuid4() #Unique identifier for spot 
    dynamodb = boto3.client('dynamodb')
    tablesinfo = "sinfo"
    dynamodb.put_item(
    TableName = tablesinfo, Item = {
      'spot_id':{'S' : str(spot_id)},
      'description': {'S' : description}
      }
    )
    return {'spot_id' : spot_id}
</code></pre>