gpt4 book ai didi

node.js - FUNCTION_ERROR_INIT_FAILURE AWS lambda

转载 作者:太空宇宙 更新时间:2023-11-03 23:12:08 26 4
gpt4 key购买 nike

我最近添加了很酷的 lambda 功能 - 配置并发

经过几次成功的部署后,我现在面临这个问题

Serverless Error ---------------------------------------

ServerlessError: An error occurred: GraphqlPrivateProvConcLambdaAlias - Provisioned Concurrency configuration failed to be applied. Reason: FUNCTION_ERROR_INIT_FAILURE. at C:\Users\theod\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\lib\monitorStack.js:125:33 From previous event: at AwsDeploy.monitorStack (C:\Users\theod\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\lib\monitorStack.js:28:12) at C:\Users\theod\AppData\Roaming\npm\node_modules\serverless\lib\plugins\aws\lib\updateStack.js:107:28 From previous event: at AwsDeploy.update

这是我的示例 serverless.yml 文件

service: backend-api

parameters:
region: ap-southeast-2
path: &path /

provider:
name: aws
runtime: nodejs12.x
stage: ${env:STAGE, 'staging'}
region: ap-southeast-2
versionFunctions: true

plugins:
- serverless-webpack
- serverless-pseudo-parameters
- serverless-prune-plugin
# - serverless-offline-scheduler
- serverless-offline

functions:
# GRAPHQL APIs
graphqlPrivate:
handler: src/graphql/private/index.handler
memorySize: 256
timeout: 30
name: ${self:service}-gqlPrivate-${self:provider.stage}
vpc: ${file(./serverless/vpc.yml)}
events:
- http:
path: /graphql/private
method: ANY
cors: true
authorizer:
arn: arn:aws:cognito-idp:#{AWS::Region}:#{AWS::AccountId}:userpool/${self:custom.cognitoArns.private.${self:provider.stage}}
provisionedConcurrency: 10


package:
individually: true

custom:
webpack:
keepOutputDirectory: true
serializedCompile: true
webpackConfig: 'webpack.config.js'
packager: 'npm'
stage: ${opt:stage, self:provider.stage}

prune:
automatic: true
number: 1

有人能解决这个问题吗?

  Your Environment Information ---------------------------
Operating System: win32
Node Version: 12.11.0
Framework Version: 1.61.3
Plugin Version: 3.2.7
SDK Version: 2.3.0
Components Core Version: 1.1.2
Components CLI Version: 1.4.0

最佳答案

FUNCTION_ERROR_INIT_FAILURE 显然意味着我尝试部署的函数的处理程序/代码有问题,这就是预配的 lambda 无法启动/初始化的原因。

解决此问题的方法是首先测试没有配置的并发选项。一旦您能够推送 lambda,错误肯定会流入您的 CW 日志中。不过,最好的方法是在本地测试您的 lambda(使用 serverless-offline 插件或 serverless invoke),看看它是否正常工作。您还可以打包应用程序,并使用无服务器 cli 调用它来检测打包问题。

就我而言,存在运行时错误,我的代码包正在寻找不属于包的require

截至目前(2020 年 1 月 29 日),AWS lambda 上尚未记录此内容

关于node.js - FUNCTION_ERROR_INIT_FAILURE AWS lambda,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59932690/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com