How to control local and non-local DynamoDB's using terraform and docker

118 views Asked by At

I am developing an app using DynamoDB, I've been testing the app using Docker with the local dynamodb image.

I've been creating the DynamoDB table on app startup from the output of the NoSQL workbench app from AWS.

I now want to start moving this to AWS using terraform.

My question is, how/where do I store my table definition, hash_key, range_key, GSI's, attributes etc. so that they can be read by terraform and be used locally to stand up a local version of the app.

I haven't been able to find any good resources on this, there must be a relatively elegant way.

1

There are 1 answers

0
Bartosz Gurgul On

Okay, if I understand correctly.

If your dynamoDb is running in some infrastructure and using Terraform to create this, you need to define all attributes right there. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table#import_table

In the local environment, I would prefer to create a local dynamoDb by Helm and a table I define by the project which works with DB. Of course, this solution is just for local dev solutions.