diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts index 4e404fcd55..b561d1f98c 100644 --- a/types/aws-lambda/aws-lambda-tests.ts +++ b/types/aws-lambda/aws-lambda-tests.ts @@ -100,6 +100,98 @@ str = customAuthorizerEvt.type; str = customAuthorizerEvt.authorizationToken; str = customAuthorizerEvt.methodArn; +/* DynamoDB Stream Event */ +var dynamoDBStreamEvent: DynamoDBStreamEvent = { + "Records": [ + { + "eventID": "1", + "eventVersion": "1.0", + "dynamodb": { + "Keys": { + "Id": { + "N": "101" + } + }, + "NewImage": { + "Message": { + "S": "New item!" + }, + "Id": { + "N": "101" + } + }, + "StreamViewType": "NEW_AND_OLD_IMAGES", + "SequenceNumber": "111", + "SizeBytes": 26 + }, + "awsRegion": "us-west-2", + "eventName": "INSERT", + "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "eventSource": "aws:dynamodb" + }, + { + "eventID": "2", + "eventVersion": "1.0", + "dynamodb": { + "OldImage": { + "Message": { + "S": "New item!" + }, + "Id": { + "N": "101" + } + }, + "SequenceNumber": "222", + "Keys": { + "Id": { + "N": "101" + } + }, + "SizeBytes": 59, + "NewImage": { + "Message": { + "S": "This item has changed" + }, + "Id": { + "N": "101" + } + }, + "StreamViewType": "NEW_AND_OLD_IMAGES" + }, + "awsRegion": "us-west-2", + "eventName": "MODIFY", + "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "eventSource": "aws:dynamodb" + }, + { + "eventID": "3", + "eventVersion": "1.0", + "dynamodb": { + "Keys": { + "Id": { + "N": "101" + } + }, + "SizeBytes": 38, + "SequenceNumber": "333", + "OldImage": { + "Message": { + "S": "This item has changed" + }, + "Id": { + "N": "101" + } + }, + "StreamViewType": "NEW_AND_OLD_IMAGES" + }, + "awsRegion": "us-west-2", + "eventName": "REMOVE", + "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", + "eventSource": "aws:dynamodb" + } + ] +}; + /* SNS Event */ snsEvtRecs = snsEvt.Records; diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index b1ca69405b..82d0bbeca0 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -54,6 +54,53 @@ interface CustomAuthorizerEvent { methodArn: string; } +// Context +// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_AttributeValue.html +interface AttributeValue { + B?: string; + BS?: Array; + BOOL?: boolean; + L?: Array; + M?: { [id: string]: AttributeValue }; + N?: number; + NS?: Array; + NULL?: boolean; + S?: string; + SS?: Array; +} + +// Context +// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_StreamRecord.html +interface StreamRecord { + ApproximateCreationTime?: number; + Keys?: { [key: string]: AttributeValue }; + NewImage?: { [key: string]: AttributeValue }; + OldImage?: { [key: string]: AttributeValue }; + SequenceNumber?: string; + SizeBytes?: number; + StreamViewType?: 'KEYS_ONLY' | 'NEW_IMAGE' | 'OLD_IMAGE' | 'NEW_AND_OLD_IMAGES'; +} + +// Context +// http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_Record.html +interface DynamoDBRecord { + awsRegion?: string; + dynamodb?: StreamRecord; + eventId?: string; + eventName?: 'INSERT' | 'MODIFY' | 'REMOVE'; + eventSource?: string; + eventVersion?: string; + userIdentity?: any; +} + +// AWS Lambda Stream event +// Context +// http://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-ddb-update +interface DynamoDBStreamEvent { + Records: Array; +} + + // SNS "event" interface SNSMessageAttribute { Type: string;