我试图使用本地堆栈在本地部署lambda,但由于无法解析变量configFile,它失败了。
我的框架版本是3
service: score-api
frameworkVersion: '3'
plugins:
- serverless-deployment-bucket
- serverless-localstack
custom:
stage: ${opt:stage, self:provider.stage}
region: ${opt:region, self:provider.region}
configFile: ${file(./config/${self:custom.stage}.json)}
serviceName: test-api
priority: 180
optionsOnly: false
redirect: false
localstack:
# list of stages for which the plugin should be enabled
stages:
- dev
host: http://localhost
autostart: true # optional - Start LocalStack in Docker on Serverless deploy
#endpoints:
# This section is optional - can be used for customizing the target endpoints
#S3: http://localhost:4572
#DynamoDB: http://localhost:4570
#CloudFormation: http://localhost:4581
#Elasticsearch: http://localhost:4571
#ES: http://localhost:4578
#SNS: http://localhost:4575
#SQS: http://localhost:4576
#Lambda: http://localhost:4574
#Kinesis: http://localhost:4568
debug: true
lambda:
mountCode: True # enable this flag for performance (True didn't work for me)
docker:
sudo: False # enable this flag to run "docker ..." commands as sudo
stages:
dev:我一直在
Running "serverless" from node_modules
Environment: darwin, node 18.2.0, framework 3.16.0 (local) 3.22.0v (global), plugin 6.2.2, SDK 4.3.2
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
Cannot resolve serverless.yml: Variables resolution errored with:
- Cannot resolve variable at "custom.configFile": Value not found at "file" source发布于 2022-11-07 15:14:31
这似乎是Serverless框架3.x版本的一个问题。我将无服务器框架版本降级为2.x,错误自行解决。
“‘npm安装-g无服务器@2’‘”
下面的链接可能有助于坚持新的变量解析方法。
https://stackoverflow.com/questions/73375643
复制相似问题