创建一个AWS HTTP API作为无服务器的资源



如何创建无服务器框架的HTTP API,以便我可以在我的。yml文件中管理它?文档显示如下:

functions:
testFunc:
name: lambdaName
handler: handler.hello
events:
- httpApi:
path: /v1/test
method: get

这将创建api,但依赖于函数,我如何在这里创建api来配置它并在函数上使用它?

我希望能够管理它在我的。yml文件

好了,我明白了。当使用serverless framework创建一个新的lambda函数时,您可以定义API类型,如我的问题中所示。现在,由于堆栈期望该类型,我也可以在我的全局变量(又名提供者)中修改它,甚至使用id在其他lambda函数之间共享资源,例如:

provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: 20201221
stage: v1 
region: us-east-1 # <- This is your regeion, make sure it is or change it
httpApi:
# id: xxx 
payload: "2.0" 
name: "v1-my-service"
cors: false 

相关内容

最新更新