【发布时间】:2021-01-13 23:00:43
【问题描述】:
我对 serverless 整体来说还很陌生,并试图在我的机器上设置 LocalStack。 我已成功将一个测试 lambda 函数部署到 LocalStack,但目前面临 API 网关问题。
使用以下配置进行部署时,一切正常,我能够使用 http 正确访问 lambda 函数,并且在部署结束时像往常一样打印生成的端点:
service: localtest
frameworkVersion: ">=1.74.1"
provider:
name: aws
runtime: nodejs12.x
stage: local
plugins:
- serverless-localstack
custom:
localstack:
stages:
- local
host: http://localhost
autostart: true
endpoints:
S3: http://localhost:4566
DynamoDB: http://localhost:4566
CloudFormation: http://localhost:4566
Elasticsearch: http://localhost:4566
ES: http://localhost:4566
SNS: http://localhost:4566
SQS: http://localhost:4566
Lambda: http://localhost:4566
Kinesis: http://localhost:4566
lambda:
mountCode: True
docker:
sudo: False
functions:
hello:
handler: handler.hello
events:
- http:
method: get
path: /
serverless deploy 的结果输出:
Service Information
service: localtest
stage: local
region: us-east-1
stack: localtest-local
resources: 10
api keys:
None
endpoints:
http://localhost:4567/restapis/720w6afoyh/local/_user_request_
functions:
hello: localtest-local-hello
layers:
None
但是,当尝试在事件中使用 httpApi 实现时
- httpApi:
method: get
path: /
我从 localstack 收到了几个错误,该函数似乎已部署但不输出路径。
来自 LocalStack 的错误日志:
2020-07-09T11:39:50:WARNING:moto: No Moto CloudFormation support for AWS::ApiGatewayV2::Integration
2020-07-09T11:39:50:WARNING:moto: No Moto CloudFormation support for AWS::ApiGatewayV2::Stage
2020-07-09T11:39:50:WARNING:moto: No Moto CloudFormation support for AWS::ApiGatewayV2::Api
2020-07-09T11:39:50:WARNING:moto: No Moto CloudFormation support for AWS::ApiGatewayV2::Route
2020-07-09T11:39:50:WARNING:moto: No Moto CloudFormation support for AWS::ApiGatewayV2::Api
2020-07-09T11:39:55:WARNING:localstack.services.cloudformation.cloudformation_starter: Unable to resolve "Ref" attribute for: {'Ref': 'HelloLambdaVersionFjNrIW0CS0DGT44Agi2AjgeDtzxVf8vf0JBR6XRariM'} - HelloLambdaVersionFjNrIW0CS0DGT44Agi2AjgeDtzxVf8vf0JBR6XRariM - <class 'moto.awslambda.models.LambdaVersion'>
【问题讨论】:
标签: aws-api-gateway serverless localstack