Question: In my db scheme, I need a autoincrement primary key. How I can realize this feature? 

PS For access to DynamoDB, I use [dynode](https://github.com/Wantworthy/dynode), module for Node.js.

Answer: 
If you're okay with gaps in your incrementing id, and you're okay with it only roughly corresponding to the order in which the rows were added, you can roll your own: Create a separate table called NextIdTable, with one primary key (numeric), call it Counter.

Each time you want to generate a new id, you would do the following:

* Do a GetItem on NextIdTable to read the current value of Counter --> curValue
* Do a PutItem on NextIdTable to set the value of Counter to curValue + 1. Make this a conditional PutItem so that it will fail if the value of Counter has changed.
* If that conditional PutItem failed, it means someone else was doing this at the same time as you were. Start over.
* If it succeeded, then curValue is your new unique ID.

Of course, if your process crashes before actually applying that ID anywhere, you'll "leak" it and have a gap in your sequence of IDs. And if you're doing this concurrently with some other process, one of you will get value 39 and one of you will get value 40, and there are no guarantees about which order they will actually be applied in your data table; the guy who got 40 might write it before the guy who got 39. But it does give you a rough ordering.

Parameters for a conditional PutItem in node.js are detailed here. <http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/frames.html#!AWS/DynamoDB.html>. If you had previously read a value of 38 from Counter, your conditional PutItem request might look like this.

```
var conditionalPutParams = {
    TableName: 'NextIdTable',
    Item: {
        Counter: {
            N: '39'
        }
    },
    Expected: {
        Counter: {
            AttributeValueList: [
                {
                    N: '38'
                }
            ],
            ComparisonOperator: 'EQ'
        }
    }
};

```
Auto Increment is not good from performance perspective as it will overload specific shards while keeping others idle, It doesn't make even distribution if you're storing data to Dynamodb.

`awsRequestId` looks like its actually V.4 UUID (Random), code snippet below to try it: 

```
exports.handler = function(event, context, callback) {
    console.log('remaining time =', context.getRemainingTimeInMillis());
    console.log('functionName =', context.functionName);
    console.log('AWSrequestID =', context.awsRequestId);
    callback(null, context.functionName);
};

```

In case you want to generate this yourself, you can use <https://www.npmjs.com/package/uuid> or [Ulide](https://github.com/ulid/javascript) to generate different versions of UUID based on [RFC-4122](http://www.ietf.org/rfc/rfc4122.txt) 

* V1 (timestamp based)
* V3 (Namespace)
* V4 (Random)

For Go developers, you can use these packages from [Google's UUID](https://github.com/google/uuid), [Pborman](https://github.com/pborman/uuid), or [Satori](https://github.com/satori/go.uuid). Pborman is better in performance, check these [articles and benchmarks](http://antoniomo.com/blog/2017/05/28/unique-ids-in-golang-part-2/) for more details. 

More Info on Universal Unique Identifier Specification could be found [here](https://en.m.wikipedia.org/wiki/Universally_unique_identifier).