Ross Coundon
05/10/2022, 10:18 AMcreateResourceTable(removalPolicy: RemovalPolicy) {
return new sst.Table(this, 'resourceTable', {
fields: {
datasetId: 'string',
resourceId: 'string',
ttl: 'number',
},
primaryIndex: { partitionKey: 'datasetId', sortKey: 'resourceId' },
cdk: {
table: {
pointInTimeRecovery: true,
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
timeToLiveAttribute: 'ttl',
removalPolicy,
},
},
});
}
but when it’s called SST is failing with:
TypeError: Cannot read property 'toUpperCase' of undefined
at Table.buildAttribute (/Users/rosscoundon/Documents/GitHub/omw-pso-be/node_modules/@serverless-stack/resources/src/Table.ts:657:22)
at Table.createTable (/Users/rosscoundon/Documents/GitHub/omw-pso-be/node_modules/@serverless-stack/resources/src/Table.ts:574:20)
at new Table (/Users/rosscoundon/Documents/GitHub/omw-pso-be/node_modules/@serverless-stack/resources/src/Table.ts:278:10)
at OmwPsoStack.createResourceTable (/Users/rosscoundon/Documents/GitHub/omw-pso-be/stacks/OmwPsoStack.ts:90:12)
at new OmwPsoStack (/Users/rosscoundon/Documents/GitHub/omw-pso-be/stacks/OmwPsoStack.ts:360:32)
This points to the buildAttribute method:
private buildAttribute(
fields: { [key: string]: TableFieldType },
name: string
): dynamodb.Attribute {
return {
name,
type: dynamodb.AttributeType[
fields[name].toUpperCase() as keyof typeof dynamodb.AttributeType
],
};
}
I can’t really see how fields[name]
is ending up undefined
Any thoughts?Ross Coundon
05/10/2022, 11:16 AMSeth Geoghegan
05/10/2022, 1:43 PMfields
, but did not define the ttl
attribute. Looks like you're having the same issueRoss Coundon
05/10/2022, 2:16 PMSeth Geoghegan
05/10/2022, 2:20 PMRoss Coundon
05/10/2022, 2:23 PMDavid Martin
05/11/2022, 4:33 AM