从下一个主要对象符号开始,"service" 属性 将不再被识别。直接用服务名设置"service" 属性

Starting from next major object notation for "service" property will no longer be recognized. Set "service" property directly with service name

在无服务器项目中,我收到以下弃用警告:

Serverless: Deprecation warning: Starting from next major object notation for "service" property will no longer be recognized. Set "service" property directly with service name. More Info: https://www.serverless.com/framework/docs/deprecations/#SERVICE_OBJECT_NOTATION

我的 Yaml 是:

service:
    name: nest
custom:
    version: ${self:service.name}-redDragon

如何修复此弃用警告?

您可以通过将服务名称直接设置为 service 属性 来修复它

service: nest
custom:
    version: ${self:service.name}-redDragon

这似乎会导致以下错误:

- Cannot resolve variable at "resources.3.Resources.IamRoleLambdaExecution.Properties.RoleName": Value not found at "self" source

设置时:

LambdaFunctionNamePrefix: ${self:provider.stage}-${self:service.name}

花了我一段时间,但如果你是 运行 无服务器的最新版本...

service: nest
custom:
  version: ${self:service}-example

不使用 self:service.name,而是使用 self:service 来引用服务名称。