AWS CloudFormation AttributeType for DynamoDb Boolean and List data types

Viewed 3897
3 Answers

Are you going to use it as an index? If not you dont need those columns there, even your template will fails that saying you have a column that not used in any indexes. Because Dynamo is schemaless. Unless you can use BOOL type as the data type.

Would recommend the following for the Boolean Field for eg: IsActive: (1) IsActive : {string} - "true/false" or "yes/no" (2) IsActive : {number} - 1 -true/yes and 0 -false/no.

The AttributeType can be {string/number/Binary} only.

BOOL is a valid data type for DynamoDB; but not for primary key attributes unfortunately. One reason for this is likely the fact that a partition key of only two possible values (true and false) does not make partitioning effective for large collections of data.

Official notes on this can be found here in AWS' documentation: Core Components of Amazon DynamoDB

Specifically:

Each primary key attribute must be a scalar (meaning that it can hold only a single value). The only data types allowed for primary key attributes are string, number, or binary. There are no such restrictions for other, non-key attributes.

Related