-
This is more of a question than an issue... Is there a way to use an existing table? I wanted to keep the basic DynamoDB table managed directly by cloudformation (using CDK) and use OneTable for all the interactions with the table, handling GSIs, etc. Is there a way to use The other way I can go about it is to use a custom resource and execute OneTable for the table creation and removal, then import the table for other resources to reference it. Would that be a better way of doing it? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Sure, all you need is a schema and call the Table constructor. In fact, this is the normal mode of operation. You don't (and shouldn't) call createTable for an existing table. createTable is really for dev and test time testing. |
Beta Was this translation helpful? Give feedback.
-
You don't call updateTable either. create/delete/update table are for making actual changes to the table keys. If you want to create or delete GSIs, then use updateTable. and yes, you could do that in a migration. For normal operation, OneTable reads the keys from the table to determine the key structure. Also, your schema should include the keys in the {indexes} section. These should (must) match the actual keys. |
Beta Was this translation helpful? Give feedback.
You don't call updateTable either. create/delete/update table are for making actual changes to the table keys.
If you want to create or delete GSIs, then use updateTable. and yes, you could do that in a migration.
For normal operation, OneTable reads the keys from the table to determine the key structure. Also, your schema should include the keys in the {indexes} section. These should (must) match the actual keys.