Hi! What is the best way to develop? Deploy dynamo...
# help
m
Hi! What is the best way to develop? Deploy dynamodb or use dynmodb-local (https://www.npmjs.com/package/serverless-dynamodb-local) and why?
r
We find dynamodb-local very useful for development and local integration testing
s
i'm in the process of building unit tests around my methods that talk to DDB. I'm hoping to mock out interactions with DDB entirely, so I don't need to rely on a functioning DDB interface.
However, I suspect i'll eventually need to use something like dynamodb-local for integration testing, since I have business logic built into my DynamoDB queries.
For example, I have transactions that conditionally PUT an item to DDB while updating a count attribute on another item. I can't imagine how to test that logic by mocking out DDB entirely
r
Yeah, that’s exactly how we use it and mock out calls for unit tests
m
Nice! I'm having 2 problems with dynamo local. First the CI is "difficult", second if I use cognito with dynamo is difficult to develop because is not a cognito offline plugin.
r
yeah, auth we’ve had to just test within AWS, not ideal, agreed. What is it you’re finding difficult on the CI side? Spinning up the docker container?
m
2 questions: • Best way to manage the env • We should test in a real dynamo or try in local dynamo in the ci
r
Which env are you referring to?
m
For example the table name. We use somehing like this notes-${stage}
r
You can do it using serverless-dotenv-plugin to set things like tableName. You could also use the built in .env support in serverless. We use a TypeScript serverless configuration rather than yaml. That gives us tonnes of flexibility to add logic into how the serverless config is created
m
TypeScript serverless configuration
with that you mean de sst?
r
No, serverless.ts
Docs are a bit sparse but there’s some info here: https://www.serverless.com/framework/docs/providers/aws/guide/intro/#services
I find it makes setting up the definition much simpler as the IDE can guide you
m
Nice! Thank you!