ahmed elkordy
10/11/2021, 3:55 AMFrank
ahmed elkordy
10/11/2021, 5:08 AMahmed elkordy
10/11/2021, 5:09 AMahmed elkordy
10/11/2021, 5:11 AMFrank
createTableInput
is:
const createTableInput = ddbGeo.GeoTableUtil.getCreateTableRequest(config);
You should be able to create the table using Table
construct.Frank
ahmed elkordy
10/11/2021, 5:28 AMahmed elkordy
10/11/2021, 5:31 AMahmed elkordy
10/11/2021, 5:41 AMahmed elkordy
10/11/2021, 6:01 AMSimon Reilly
10/11/2021, 6:45 AMyarn test
and adding table props till it passed.
import { expect, haveResource } from '@aws-cdk/assert';
import * as sst from '@serverless-stack/resources';
import MyStack from '../stacks/MyStack';
test('Test Stack', () => {
const app = new <http://sst.App|sst.App>();
// WHEN
const stack = new MyStack(app, 'test-stack');
// THEN
expect(stack).to(
haveResource('AWS::DynamoDB::Table', {
TableName: 'yourTableName',
ProvisionedThroughput: {
ReadCapacityUnits: 2,
WriteCapacityUnits: 5,
},
KeySchema: [
{ KeyType: 'HASH', AttributeName: 'hashKey' },
{ KeyType: 'RANGE', AttributeName: 'rangeKey' },
],
AttributeDefinitions: [
{ AttributeName: 'hashKey', AttributeType: 'N' },
{ AttributeName: 'rangeKey', AttributeType: 'S' },
{ AttributeName: 'geohash', AttributeType: 'N' },
],
LocalSecondaryIndexes: [
{
IndexName: 'geohash-index',
KeySchema: [
{ KeyType: 'HASH', AttributeName: 'hashKey' },
{ KeyType: 'RANGE', AttributeName: 'geohash' },
],
Projection: { ProjectionType: 'ALL' },
},
],
})
);
});
ahmed elkordy
10/11/2021, 6:47 AMRoss Coundon
10/11/2021, 7:07 AMnew sst.Table(this, 'myTable', {
stream: dynamodb.StreamViewType.NEW_AND_OLD_IMAGES,
fields: {
PK: sst.TableFieldType.STRING,
SK: sst.TableFieldType.STRING,
},
primaryIndex: { partitionKey: 'PK', sortKey: 'SK' },
globalIndexes: {
GSI1: {
partitionKey: 'SK',
sortKey: 'PK',
indexProps: {
projectionType: dynamodb.ProjectionType.ALL,
},
},
},
...
ahmed elkordy
10/11/2021, 7:11 AMFrank
Frank
ahmed elkordy
10/11/2021, 4:32 PM