How to solve Error: "Deployment failed: RESOURCE_ERROR" (The GCF v1beta2 API is deprecated) when deploying serverless GCP?
How to solve Error: "Deployment failed: RESOURCE_ERROR" (The GCF v1beta2 API is deprecated) when deploying serverless GCP?
不知道为什么,但无服务器 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
Google 实际上弃用了他们之前版本的 Cloud Functions API。 Google Cloud Functions 提供程序的更改时间不长,您可能还不知道,因此请尝试使用 npm i -g serverless
升级框架,它应该可以解决问题。如果失败,请尝试查看您使用的 serverless-google-cloudfunctions
模块的哪个版本并升级它。
如果您使用无服务器框架在 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
.
通过 serverless.com 模板安装时,package.json
引用了 "serverless-google-cloudfunctions": "^2.3.3"
。版本 2.x 是问题所在。重新安装版本 3.x.
的软件包
我删除了 package.json
和 运行 npm install serverless-google-cloudfunctions
中的那一行。
这安装了版本 ^3.1.1
并且我的 serverless deploy
成功了。
"dependencies": { "serverless-google-cloudfunctions": "^2.3.3"
} package.json 更改版本 '^3.0.0'
不知道为什么,但无服务器 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
Google 实际上弃用了他们之前版本的 Cloud Functions API。 Google Cloud Functions 提供程序的更改时间不长,您可能还不知道,因此请尝试使用 npm i -g serverless
升级框架,它应该可以解决问题。如果失败,请尝试查看您使用的 serverless-google-cloudfunctions
模块的哪个版本并升级它。
如果您使用无服务器框架在 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
.
通过 serverless.com 模板安装时,package.json
引用了 "serverless-google-cloudfunctions": "^2.3.3"
。版本 2.x 是问题所在。重新安装版本 3.x.
我删除了 package.json
和 运行 npm install serverless-google-cloudfunctions
中的那一行。
这安装了版本 ^3.1.1
并且我的 serverless deploy
成功了。
"dependencies": { "serverless-google-cloudfunctions": "^2.3.3"
} package.json 更改版本 '^3.0.0'