Have you guys considered providing the ability to ...
# sst
r
Have you guys considered providing the ability to run a subset of functions locally? For example, maybe I’ve got some heavy lifting cron based functions that chug away and move data around from APIs into databases. I’m happy with those and I’m happy for them to carry on running in AWS. However, I’m developing a lambda attached to an API route that uses that data which I want to debug locally? I guess it could also be useful in a situation where there is a last resort emergency production issue that could be quickly identified by updating the stack to run that single function locally but have all the others carry on as they were.
f
Hey @Ross Coundon, currently you can turn on/off Live Lambda dev for an individual function using the
enableLiveDev
flag, like this:
Copy code
new Function(this, "MyFn", {
  handler: "lambda/index.main",
  enableLiveDev: false,
});
Does that help?
s
Along with what Frank mentioned about
enableLiveDev
. If you’re wanting to disable some lambdas from being triggered by event sources like you mentioned regarding cronjob. What I’ve done in general is conditionally disabled cronjobs on my local dev stacks. SST Cron or CDK event targets construct have a prop
enabled
that is
true
by default that I used. If it’s
false
the cron schedule won’t trigger the lambda. I think most, if not all event sources constructs have this
enabled
prop. I would then trigger them manually with CLI or much better with SST console to run the lambda when needed on local for testing etc.
Copy code
new sst.Cron(this, 'CronJob', {
  schedule: 'rate(1 minute)',
  job: 'index.main',
  eventsRule: {
    enabled: !scope.local,
  },
})
r
Thanks guys, both of those things are useful to know. @Frank not quite, I was more thinking of being able to run
sst start
with an option to only debug a single lambda, or maybe a small handful of lambdas without needing to touch the code. This could be via a CLI option e.g.
sst start --enable-for some-lambda-func-name,some-other-lambda-func-name
a
Some of the reasoning is not longer valid: • SST live lambda has become much quicker since then • Console allows easier groking of a single function's logs
f
@Ross Coundon does enable by stack help? Enabling by lambdas might be tricky as the function names might be hard to figure out?
Copy code
sst start --enable-for some-lambda-func-name,some-other-lambda-func-name
r
Unfortunately, not really for us, as each deployment is typically all included in a single stack as we’re building lots of different things separately for different customers.
f
I see. Are you hard coding the function names?
r
No, I was thinking we’d be able to find them out from the cloudwatch outputs/Seed resources
f
It’s likely we add support for selectively live debugging a stack first. But if this becomes a bigger headache, lemme know and I will bump up the priority.
r
No worries