Full-stack example for dynamo db database with string set

I am using ful-stack boilerplate to start coding and one thing I noticed that serverless.yml doesn’t support string set for dynamodb.

Error that I am getting is following:
ValidationException: 1 validation error detected: Value ‘SS’ at ‘attributeDefinitions.6.member.attributeType’ failed to satisfy constraint: Member must satisfy enum value set: [B, N, S]

here is my yaml file

component: aws-dynamodb
name: project
inputs:
name: project-${stage}
region: ca-central-1

deletionPolicy: delete

attributeDefinitions:
- AttributeName: ProjectId
AttributeType: S
- AttributeName: CustomerId
AttributeType: S
- AttributeName: Name
AttributeType: S
- AttributeName: CreatedOn
AttributeType: S
- AttributeName: CreatedBy
AttributeType: S
- AttributeName: Files
AttributeType: SS
keySchema:
- AttributeName: CustomerId
KeyType: HASH
- AttributeName: ProjectId
KeyType: RANGE
globalSecondaryIndexes:
- IndexName: gsi1
KeySchema:
- AttributeName: Name
KeyType: HASH
Projection:
ProjectionType: ALL

That’s not a limitation of Serverless. It’s a limitation of DynamoDB.
While you can use StringSet as a data type for non-indexed values, it can’t be applied to an Indexed attribute.
See: AWS Reference - CloudFormation Attribute Definitions

tldr; Only String, Binary & Number types are available for keys/indexes

Here’s a screen capture from the AWS DynamoDB Console creating a Table:

1 Like