File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
test/integration-tests/scripts Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 3535 - name : Start DynamoDB Local
3636 run : docker run -d -p 8000:8000 amazon/dynamodb-local
3737
38+ - name : Create Rooms table for testing
39+ run : node scripts/create-local-table.js
40+
3841 - name : Set up env vars
3942 run : |
4043 echo "AWS_ACCESS_KEY_ID=FAKE_KEY" >> $GITHUB_ENV
Original file line number Diff line number Diff line change 1+ // scripts/create-local-table.js
2+ // This is used to create a test table in our local copy of DynamoDB when the tests run
3+ // This is not used if deploying infrastructure to AWS
4+ const { DynamoDBClient, CreateTableCommand } = require ( '@aws-sdk/client-dynamodb' ) ;
5+
6+ ( async ( ) => {
7+ try {
8+ const client = new DynamoDBClient ( {
9+ region : process . env . AWS_REGION || "us-west-2" ,
10+ endpoint : process . env . DYNAMODB_ENDPOINT || "http://localhost:8000" ,
11+ credentials : {
12+ accessKeyId : process . env . AWS_ACCESS_KEY_ID || "FAKE_KEY" ,
13+ secretAccessKey : process . env . AWS_SECRET_ACCESS_KEY || "FAKE_SECRET" ,
14+ } ,
15+ } ) ;
16+
17+ const tableName = process . env . DYNAMODB_TABLE_NAME || "RoomsTest" ;
18+
19+ const command = new CreateTableCommand ( {
20+ TableName : tableName ,
21+ AttributeDefinitions : [
22+ { AttributeName : 'id' , AttributeType : 'N' } ,
23+ ] ,
24+ KeySchema : [
25+ { AttributeName : 'id' , KeyType : 'HASH' } ,
26+ ] ,
27+ ProvisionedThroughput : {
28+ ReadCapacityUnits : 5 ,
29+ WriteCapacityUnits : 5 ,
30+ } ,
31+ SSESpecification : {
32+ Enabled : true , // server-side encryption
33+ } ,
34+ } ) ;
35+
36+ const result = await client . send ( command ) ;
37+ console . log ( `Created table '${ tableName } ' locally.` , result . TableDescription ?. TableStatus ) ;
38+ } catch ( err ) {
39+ console . error ( 'Error creating table locally:' , err ) ;
40+ process . exit ( 1 ) ;
41+ }
42+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments