Skip to content

Commit 018df94

Browse files
author
Barry Steyn
committed
aws dynamodb global table with index support
1 parent 60a319a commit 018df94

File tree

4 files changed

+51
-5
lines changed

4 files changed

+51
-5
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.vscode
2+
.env
3+
node_modules
4+
yarn.lock
5+
.serverless

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"jest": "^24.9.0"
1818
},
1919
"dependencies": {
20-
"@serverless/aws-dynamodb": "git+https://github.com/danielcondemarin/aws-dynamodb.git#global-tables-supported",
20+
"@serverless/aws-dynamodb": "git+https://github.com/barrysteyn/aws-dynamodb.git#global-tables-supported-with-indexes_barry-branch",
2121
"@serverless/core": "^1.0.0",
2222
"ramda": "^0.26.1"
2323
}

serverless.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class GlobalDynamoDBTableComponent extends Component {
2020
globalTableName,
2121
regions,
2222
attributeDefinitions,
23-
keySchema
23+
keySchema,
24+
localSecondaryIndexes,
25+
globalSecondaryIndexes
2426
) {
2527
const createTables = regions.map(async region => {
2628
const dynamodb = await this.load(
@@ -33,8 +35,10 @@ class GlobalDynamoDBTableComponent extends Component {
3335
return dynamodb({
3436
name: globalTableName,
3537
region,
36-
attributeDefinitions: attributeDefinitions,
37-
keySchema: keySchema,
38+
attributeDefinitions,
39+
keySchema,
40+
localSecondaryIndexes,
41+
globalSecondaryIndexes,
3842
stream: true
3943
});
4044
});
@@ -98,7 +102,9 @@ class GlobalDynamoDBTableComponent extends Component {
98102
inputTableName,
99103
addRegions,
100104
inputs.attributeDefinitions,
101-
inputs.keySchema
105+
inputs.keySchema,
106+
inputs.localSecondaryIndexes,
107+
inputs.globalSecondaryIndexes
102108
);
103109

104110
await this.deleteTableFromRegions(inputTableName, deleteRegions);

testproject/serverless.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
myGlobalTable:
2+
component: "../"
3+
inputs:
4+
tableName: myGlobalTable
5+
replicationGroup:
6+
- "eu-west-1"
7+
- "us-west-1"
8+
attributeDefinitions:
9+
- AttributeName: id
10+
AttributeType: S
11+
- AttributeName: attribute1
12+
AttributeType: N
13+
- AttributeName: attribute2
14+
AttributeType: S
15+
keySchema:
16+
- AttributeName: id
17+
KeyType: HASH
18+
- AttributeName: attribute1
19+
KeyType: RANGE
20+
localSecondaryIndexes:
21+
- IndexName: 'myLocalSecondaryIndex'
22+
KeySchema:
23+
- AttributeName: id
24+
KeyType: HASH
25+
- AttributeName: attribute2
26+
KeyType: RANGE
27+
Projection:
28+
ProjectionType: 'KEYS_ONLY'
29+
globalSecondaryIndexes:
30+
- IndexName: 'myGlobalSecondaryIndex'
31+
KeySchema:
32+
- AttributeName: attribute2
33+
KeyType: HASH
34+
Projection:
35+
ProjectionType: 'KEYS_ONLY'

0 commit comments

Comments
 (0)