无服务器获取本地函数列表

6

场景

我正在为本地 Lambda 输出编写单元测试。与手动输入所有不同 Lambda 函数的名称不同,我希望动态生成列表。

sls deploy list functions

将返回部署到AWS的函数列表,但不包括本地serverless环境中的函数。

问题

如何获取本地函数列表?

帮助菜单可以指导如何运行本地函数,但无法列出本地函数列表。

$ sls --help

Commands
* You can run commands with "serverless" or the shortcut "sls"
* Pass "--verbose" to this command to get in-depth plugin info
* Pass "--no-color" to disable CLI colors
* Pass "--help" after any <command> for contextual help

Framework
* Documentation: https://serverless.com/framework/docs/

config ........................ Configure Serverless
config credentials ............ Configures a new provider profile for the Serverless Framework
create ........................ Create new Serverless service
deploy ........................ Deploy a Serverless service
deploy function ............... Deploy a single function from the service
deploy list ................... List deployed version of your Serverless Service
deploy list functions ......... List all the deployed functions and their versions
info .......................... Display information about the service
install ....................... Install a Serverless service from GitHub or a plugin from the Serverless registry
invoke ........................ Invoke a deployed function
invoke local .................. Invoke function locally
logs .......................... Output the logs of a deployed function
metrics ....................... Show metrics for a specific function
package ....................... Packages a Serverless service
plugin ........................ Plugin management for Serverless
plugin install ................ Install and add a plugin to your service
plugin uninstall .............. Uninstall and remove a plugin from your service
plugin list ................... Lists all available plugins
plugin search ................. Search for plugins
print ......................... Print your compiled and resolved config file
remove ........................ Remove Serverless service and all resources
rollback ...................... Rollback the Serverless service to a specific deployment
rollback function ............. Rollback the function to a specific version
slstats ....................... Enable or disable stats

Platform (Beta)
* The Serverless Platform is currently in experimental beta. Follow the docs below to get started.
* Documentation: https://serverless.com/platform/docs/

emit .......................... Emits an event to a running Event Gateway
login ......................... Login or sign up for the Serverless Platform
logout ........................ Logout from the Serverless Platform
run ........................... Runs the Event Gateway and the Emulator

你在这方面有什么进展吗? - RMK
@RMK 我们最终转向使用SAM本地,对整个团队来说效果要好得多。祝好运! - Jacksonkr
1个回答

5
serverless info

这将产生以下结果:
Service Information
service: <>
stage: <>
region: <>
stack: <>
api keys:
  <>
endpoints:
  <>
functions:
  <List of function names>

你的自我回答对我有用!请将您自己的答案标记为正确答案。 - Ryan Grow
我和提问者不是同一个人。 - user 923227
2
这仅适用于远程函数,不适用于本地函数。 - Basil Aiman

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接