コチラの方が、参考になったかな。
Dynamo DBトリガの水平トリムか?最新か?の話です。
(引用)
Starting Position」というのは読み取りを開始する位置を表します「Latest(最新のものから順番に読み取る)」と「Trim horizon(読み取りされていないものを古い順から読み取る)」の2種類から選択します。時間順にデータを処理するならTrim horizon、最新のデータを使用する設計ならLatestを選びましょう。
import boto3
# Get the service resource.
dynamodb = boto3.resource('dynamodb')
def lambda_handler(event, context):
# Create the DynamoDB table.
table = dynamodb.create_table(
TableName='LineData',
KeySchema=[
{
'AttributeName': 'UserId',
'KeyType': 'HASH'
},
{
'AttributeName': 'MessageId',
'KeyType': 'RANGE'
}
],
AttributeDefinitions=[
{
'AttributeName': 'UserId',
'AttributeType': 'S'
},
{
'AttributeName': 'MessageId',
'AttributeType': 'N'
},
],
ProvisionedThroughput={
'ReadCapacityUnits': 5,
'WriteCapacityUnits': 5
}
)