• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

silvermine / cloudformation-custom-resources / 25378473900

05 May 2026 01:12PM UTC coverage: 0.0%. Remained the same
25378473900

push

github

web-flow
Merge pull request #29 from MrMarCode/MrMarCode/upgrade-node-24

Mr mar code/upgrade node 24

0 of 117 branches covered (0.0%)

Branch coverage included in aggregate %.

0 of 270 new or added lines in 6 files covered. (0.0%)

6 existing lines in 3 files now uncovered.

0 of 356 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/SimpleDynamoDBGlobalTable.js
1
'use strict';
2

NEW
3
const _ = require('underscore'),
×
NEW
4
      BaseResource = require('./BaseResource');
×
5

6
const {
7
   DynamoDBClient,
8
   CreateGlobalTableCommand,
9
   UpdateGlobalTableCommand,
10
   DescribeGlobalTableCommand,
NEW
11
} = require('@aws-sdk/client-dynamodb');
×
12

NEW
13
const dynamo = new DynamoDBClient({});
×
14

15
class SimpleDynamoDBGlobalTable extends BaseResource {
16

17
   normalizeResourceProperties(props) {
18
      if (props.Regions) {
×
NEW
19
         props.ReplicationGroup = _.map(props.Regions, (dr) => {
×
20
            return { RegionName: dr.region };
×
21
         });
22
      }
23

24
      return props;
×
25
   }
26

27
   async doCreate(props) {
NEW
28
      const params = _.pick(props, 'GlobalTableName', 'ReplicationGroup');
×
29

30
      console.log('Creating global table: %j', params);
×
31

NEW
32
      const resp = await dynamo.send(new CreateGlobalTableCommand(params));
×
33

NEW
34
      console.log('createGlobalTable response: %j', resp);
×
NEW
35
      return { PhysicalResourceId: props.GlobalTableName, Arn: resp.GlobalTableDescription.GlobalTableArn };
×
36
   }
37

38
   async doUpdate(resourceID, props) {
NEW
39
      const desc = await this._describeGlobalTable(props.GlobalTableName),
×
NEW
40
            tableName = props.GlobalTableName,
×
NEW
41
            desiredRegions = _.pluck(props.ReplicationGroup, 'RegionName'),
×
NEW
42
            existingRegions = _.pluck(desc.ReplicationGroup, 'RegionName'),
×
NEW
43
            params = { GlobalTableName: tableName, ReplicaUpdates: [] };
×
44

NEW
45
      console.log('Updating global table %s to match props %j', tableName, props);
×
NEW
46
      console.log('The description of the current global table %s is: %j', tableName, desc);
×
47

48
      // add missing regions:
NEW
49
      _.each(_.difference(desiredRegions, existingRegions), (region) => {
×
NEW
50
         params.ReplicaUpdates.push({ Create: { RegionName: region } });
×
51
      });
52

53
      // remove extra regions:
NEW
54
      _.each(_.difference(existingRegions, desiredRegions), (region) => {
×
NEW
55
         params.ReplicaUpdates.push({ Delete: { RegionName: region } });
×
56
      });
57

NEW
58
      if (_.isEmpty(params.ReplicaUpdates)) {
×
NEW
59
         console.log('No update needed for global table %s', tableName);
×
NEW
60
         return { PhysicalResourceId: props.GlobalTableName, Arn: desc.GlobalTableArn };
×
61
      }
62

NEW
63
      console.log('Updating global table %s with params: %j', tableName, params);
×
NEW
64
      await dynamo.send(new UpdateGlobalTableCommand(params));
×
65

NEW
66
      return { PhysicalResourceId: props.GlobalTableName, Arn: desc.GlobalTableArn };
×
67
   }
68

69
   async doDelete(resourceID, props) {
70
      console.log('No need to do anything to delete global table %s - just delete the tables in it', props.GlobalTableName);
×
NEW
71
      return { PhysicalResourceId: props.GlobalTableName };
×
72
   }
73

74
   async _describeGlobalTable(tableName) {
NEW
75
      const resp = await dynamo.send(new DescribeGlobalTableCommand({ GlobalTableName: tableName }));
×
76

NEW
77
      return resp.GlobalTableDescription;
×
78
   }
79

80
}
81

NEW
82
module.exports = SimpleDynamoDBGlobalTable;
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc