不知道为什么没有服务器的GCP成功地进行了部署,因此停止了错误的处理:
team27> serverless deploy -c serverless_stage.yml
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Compiling function "user"...
Serverless: Compiling function "volunteer"...
Serverless: Compiling function "clear"...
Serverless: Uploading artifacts...
Serverless: Artifacts successfully uploaded...
Serverless: Updating deployment...
Serverless: Checking deployment update progress...
..
Error --------------------------------------------------
Error: Deployment failed: RESOURCE_ERROR
{"ResourceType":"cloudfunctions.v1beta2.function","ResourceErrorCode":"403","ResourceErrorMessage":{"code":403,"message":"The GCF v1beta2 API is deprecated. See https://cloud.google.com/functions/docs/migrating","status":"PERMISSION_DENIED","details":[],"statusMessage":"Forbidden","requestPath":"https://cloudfunctions.googleapis.com/v1beta2/projects/stageteam27/locations/us-central1/functions","httpMethod":"POST"}}
at throwErrorIfDeploymentFails (xxx\team27\node_modules\serverless-google-cloudfunctions\shared\monitorDeployment.js:71:11)
at xxx\team27\node_modules\serverless-google-cloudfunctions\shared\monitorDeployment.js:42:17
at processTicksAndRejections (internal/process/task_queues.js:93:5)
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: win32
Node Version: 12.13.1
Framework Version: 1.64.0
Plugin Version: 3.4.0
SDK Version: 2.3.0
Components Core Version: 1.1.2
Components CLI Version: 1.4.0正如https://cloud.google.com/functions/docs/migrating中所建议的,我执行了gcloud components update相同的错误..。
这是我的yml:
service: stageteam27
provider:
name: google
stage: stage
runtime: nodejs10
region: us-central1
project: stageteam27
credentials: /xxx/stageteam27keyfile.json
environment:
IS_PROD: 'false'
plugins:
- serverless-google-cloudfunctions
package:
exclude:
- node_modules/**
- .gitignore
- .git/**
functions:
user:
handler: userMessage
events:
- http: user
volunteer:
handler: volunteerMessage
events:
- http: volunteer
clear:
handler: clearCommand
events:
- http: clear发布于 2020-06-30 14:36:54
如果使用无服务器框架在GCP中部署云功能,下面的引用可能会对您有所帮助,
https://github.com/serverless/serverless-google-cloudfunctions/blob/HEAD/MIGRATION_GUIDE.md
选项2
第二个是从开发人员的角度来看,这意味着您需要对serverless.yml进行一些更改。
1. Change the service name or change the function name to make sure this function is different from the older one.
2. Redeploy the functions.
3. Once it's done,you may consider delete the old ones.除了将serverless库和serverless-google-cloudfunctions插件升级到最新版本之外,还可以尝试将服务重命名为stageteam27以外的其他名称(例如stageteam27-v2、stageteam27-new或stage-team-27)。
在我的例子中,只有重命名函数才能解决部署问题,而服务名称仍然是旧的。
只需注意一个问题,即函数名现在将具有以下模式${serviceName}-${stage}-${functionName}。
编辑
如果我们不想有这么长的函数名,我们可以在serverless.yml中指定函数名。
例如
service: myService
provider:
name: google
stage: prod
runtime: nodejs10
functions:
myFunction:
# this will be the function name
name: myFunction
handler: myFunctionHandler在这种情况下,部署的函数名将仅为myFunction。如果我们不指定名称,它将是myService-prod-myFunction。
发布于 2020-06-30 13:03:58
Google实际上反对他们以前版本的。对所做的更改不会太久,您可能还没有这样做,所以尝试使用npm i -g serverless升级框架,它应该会修复这个问题。如果失败,请尝试查看您使用的serverless-google-cloudfunctions模块的哪个版本,并对其进行升级。
发布于 2020-10-01 23:53:38
通过serverless.com模板安装时,package.json引用了"serverless-google-cloudfunctions": "^2.3.3"。2.x版是问题所在。用3.x版重新安装软件包。
我删除了package.json中的这一行,并运行了npm install serverless-google-cloudfunctions。
安装的versoin ^3.1.1和我的serverless deploy工作正常。
https://stackoverflow.com/questions/62657895
复制相似问题