Skip to content

Commit a89bfaa

Browse files
Merge pull request #8 from replicon/sf-2432
SF-2432: Migrate from AWS SDK v2 to v3
2 parents 6755002 + 3c84c4a commit a89bfaa

5 files changed

Lines changed: 2041 additions & 25 deletions

File tree

index.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"use strict";
22

3-
const aws = require('aws-sdk');
3+
const { DynamoDB } = require('@aws-sdk/client-dynamodb');
4+
const { DynamoDBStreams } = require('@aws-sdk/client-dynamodb-streams');
5+
const { unmarshall } = require('@aws-sdk/util-dynamodb');
6+
47
const EventEmitter = require('events').EventEmitter;
58
const schedule = require('tempus-fugit').schedule;
69
const ms = require('ms');
@@ -29,11 +32,13 @@ class DynamodDBSubscriber extends EventEmitter {
2932
}
3033

3134
this._ddbStream = params.endpoint
32-
? new aws.DynamoDBStreams({
33-
region: params.region,
34-
endpoint: params.endpoint
35-
})
36-
: new aws.DynamoDBStreams({ region: params.region });
35+
? new DynamoDBStreams({
36+
region: params.region,
37+
endpoint: params.endpoint
38+
})
39+
: new DynamoDBStreams({
40+
region: params.region
41+
});
3742
}
3843

3944
_getOpenShards (callback) {
@@ -119,7 +124,7 @@ class DynamodDBSubscriber extends EventEmitter {
119124

120125
if (data.Records && data.Records.length > 0) {
121126
data.Records.forEach(r => {
122-
const key = r.dynamodb && r.dynamodb.Keys && aws.DynamoDB.Converter.output({M: r.dynamodb.Keys});
127+
const key = r.dynamodb && r.dynamodb.Keys && unmarshall(r.dynamodb.Keys);
123128
this.emit('record', r, key);
124129
});
125130
}
@@ -159,8 +164,13 @@ class DynamodDBSubscriber extends EventEmitter {
159164
cb => {
160165
if (this._streamArn) { return cb(); }
161166
const dynamo = this._endpoint
162-
? new aws.DynamoDB({ region: this._region, endpoint: this._endpoint })
163-
: new aws.DynamoDB({ region: this._region });
167+
? new DynamoDB({
168+
region: this._region,
169+
endpoint: this._endpoint
170+
})
171+
: new DynamoDB({
172+
region: this._region
173+
});
164174
dynamo.describeTable({ TableName: this._table }, (err, tableDescription) => {
165175
if (err) {
166176
return cb();

0 commit comments

Comments
 (0)