Hey guys, I’m using `DockerImageFunction` construc...
# sst
a
Hey guys, I’m using
DockerImageFunction
construct from CDK into my SST stack. How can I test this locally? Can I run the docker image locally? and how I can connect to Dynamo and others? is that possible from LOCAL?
t
We currently don't support docker functions for local debugging
a
I know, but apart from SST.
Is there a workaround? or how should I test it?
t
ah sorry misread
It's pretty hard to test it by spinning up the image, I'd test theu nderlying code it's calling from outside docker
a
So I’m running python functions in docker.
Maybe I can just test the python code, somehow.
d
By
test
, do you mean unit test? It sounds more like you mean running a local dev environment, in which case I believe the answer will depend how the lambda is invoked.
a
Test I mean... Human test, the developer invoking it.
d
whats the trigger?
and you should be really sure whatever you are trying to do cant be handled in unit tests, its gonna be unpleasant, lol
for most triggers, id just pull the handler into a file, run it with whatever variables you want, and execute the file with
AWS_PROFILE
env variable populated
this is essentially a unit test, but no stubs
s
You can test it locally with the runtime interface operator How to do this using curl is in the official docs https://docs.aws.amazon.com/lambda/latest/dg/images-create.html For including dynamodb you could do further local emulation. Or use something like wiremock or robohydra to perform intercepts. I do wonder though if ultimately testing in aws will be easier?
d
I do wonder though if ultimately testing in aws will be easier?
I think so. https://dev.to/garethmcc/why-local-development-for-serverless-is-an-anti-pattern-1d9b
there is a reason why SST is so awesome 😉