I need to debug Step Functions locally. Each workflow step in Step Functions is a separate lambda. If I wont to debug entire workflow step-by-step as described here: Debug Lambda functions from your IDE using LocalStack do I need to add a wait for debug to each lambda?
But debugger can be connected trough only one port: can I debug a couple lambdas in parallel in such way?
It seems like I need to start debugger before each lambda (such moment will be very hard to catch):
LocalStack’s new Lambda Debug Mode seems to be the right tool to address the two limitations you encountered: debugging multiple lambda functions and dealing with timeouts. This feature is currently in preview and will undergo significant development improvements and refinements over the next few releases. However, you may already find it useful. You can enable Lambda Debug Mode by setting the environment variable LAMBDA_DEBUG_MODE=1
and passing a configuration file for the debug mode through LAMBDA_DEBUG_MODE_CONFIG_PATH=path/to/debug.yaml
(the file should be mounted if LocalStack is running in Docker). By enabling Lambda Debug Mode, you’ll have all the time required to connect to the lambda functions you wish to debug. In the configuration file, you can list the lambda ARNs you wish to debug, along with the debug port on which they will be available for remote debugging. For example:
functions:
arn:aws:lambda:us-east-1:000000000000:function:function-one:
debug-port: 5050
arn:aws:lambda:us-east-1:000000000000:function:function-two:
debug-port: 5051
The debug-port
field assumes both the debugger and the remote debug client will use the same port. This is something we are working on improving. However, for now, it means that jdwp
should be configured to match this preference for each lambda function at the time of creation using the environment parameter. For example:
--environment '{"Variables": {"_JAVA_OPTIONS": "-Xshare:off -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=0.0.0.0:5050"}}'
--environment '{"Variables": {"_JAVA_OPTIONS": "-Xshare:off -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=0.0.0.0:5051"}}'
I hope this helps and would be happy to hear your thoughts on this matter!
Hi, do I need to assign to each debugged lambda a separate port?
Correct. In the example I shared earlier, function-one
will be debuggable on port 5050, and function-two
on port 5051. All other lambda functions would not be debuggable.
1 Like