3
votes

I am trying to use AWS CloudFormation for creating an AWS DynamoDB table,
I am confused as to what to specify for a Boolean data type in the table,
in the template file.

My data on the table shows as type Boolean -

enter image description here

Also got a List type data -
enter image description here

But on the Doc it shows it has only 3 types to specify -

enter image description here

I am following this CloudFormation ref doc -

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html

3

3 Answers

2
votes

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.

2
votes

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.

0
votes

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.