Because lambdas are stateless and multiple instances can run at the same time it might be a bad idea to generate ids based on timestamps. I am currently using UUIDv1. I know the chance of generating the same IDs with the same timestamp already literally impossible. It's also enough unique enough for my application. Out of curiosity I'm thinking of ways to generate truly mathematically unique ids on aws lambda.
UUID v1 uses a node to distinct ids generated with the same timestamp. Random numbers or MAC-Adresses (bad idea for virtual instances) are used to create node ids.
If I had a unique id for my active lambda instance I would be able to generate truly unique ids. There is a awsRequestId inside the context object but it just seems like another timestamp based UUID.
Maybe you guys have more ideas?
AWS lambda:
System.getenv("AWS_LAMBDA_LOG_STREAM_NAME").replaceFirst(".*?(?=\\w+$)", EMPTY)
Defined runtime environment variables
AWS EC2:
httpGet http://169.254.169.254/latest/meta-data/instance-id
Instance metadata and user data
AWS ECS:
httpGet http://localhost:51678/v1/metadata