How do we create the actual table in aws dynamodb?
Preference is to not have two definitions for the same table: So how can we either create a table through the api or/and generate a cloudformation template?
If this is out of the scope of this library, I'd really like to understand what the best practices are!
PS: So far this library is looking promising and we are liking what we are seeing. Thank you for your help!
Hi @simlu! The library is intended to be a wrapper over the existing DynamoDB API to make interactions easier. The table definition in your app code should only need to identify your partition and sort keys, plus map your secondary indexes if you have any.
I don’t think the library would want to add additional API wrappers for “management” tasks. How would you envision a interface for generating CF?
@simlu the way I work it is to define the table in CF and this is then provisioned on first deploy.
The code (Table entity) doesn't generate the table, just maps to the existing table.
I would recommend using CloudFormation where possible.
@jeremydaly This is what we envisioned and now implemented. Maybe as an inspiration for you
https://github.com/blackflux/aws-sdk-wrap/blob/master/src/module/dy/create-model.js#L57-L80
@simlu are you generating one table per entity?
@darbio That is correct. We have persistent data requirements
Ok. I can see why you would want to define tables like this in that case.
However, general 'wisdom' is that you have one table and you put all of your data in that table so I don't think we want to encourage multi table environments (though they absolutely are possible).
With one table design the cloud formation definition is perfect.
Can I ask, what are your data concerns on a single table? I've always found that the benefits outweigh the cons, and especially with a library such as this one.
Refs:
- https://alexdebrie.com/posts/dynamodb-single-table/
- https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-general-nosql-design.html
For anyone else who arrives at this question solely based on the subject line - and is not interested in the CloudFormation aspect. I have a gist that you may find helpful...or not.
- https://gist.github.com/ericdmoore/39c3d02ed8a4aca3afce8120654f7183
Hey, thanks for opening this issue 🙏
I'll be closing it because it does seem like out of scope for the library and the comments seem to pretty much resolve this.
Please let me know if this issue needs to be re-open