I'm working on a Serverless web application and I'm trying to create a CloudFormation YAML template for a DynamoDB table. The documentation says that each attribute in the table should follow the style below, where AttributeType can be either 'S', 'N' or 'B', for string, number or binary.
AttributeName: String
AttributeType: String
My table includes attributes that are maps. How do I include them in the template?
S - the attribute is of type String.
DynamoDB uses three basic data model units, Tables, Items, and Attributes. Tables are collections of Items, and Items are collections of Attributes.
In Amazon DynamoDB, an item is a collection of attributes. Each attribute has a name and a value. An attribute value can be a scalar, a set, or a document type. For more information, see Amazon DynamoDB: How it works. DynamoDB provides four operations for basic create, read, update, and delete (CRUD) functionality.
When creating the Dynamodb table, you dont need to mention all the attributes of the table. Only two attributes are mandatory while creating the table I.e. partition key and sort key if available.
As you have mentioned that the attribute is map, definitely it can't be partition key or sort key because key attributes can only be scalar data type.
The simple answer is you dont need to define the map attribute (document data type) in CloudFormation create table script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With