无服务器框架 - 新变量解析器

Serverless framework - New variables resolver

当我 运行 sls offline - 我面临弃用警告时:

Serverless: Deprecation warning: Variables resolver reports following resolution errors: - Variable syntax error at "functions.Test.environment.TEST_URL": Invalid variable type at index 20 in "${file(./env.yml):${'${self:provider.stage}.TEST_URL'}}" From a next major this will be communicated with a thrown error. Set "variablesResolutionMode: 20210326" in your service config, to adapt to new behavior now

Documentation不清楚

env.yml

dev: 
  TEST_URL: https://example.com/

serverless.yml

frameworkVersion: '2'

...

functions:
  Test:
    handler: handler.test
    environment:
      TEST_URL: ${file(./env.yml):${'${self:provider.stage}.TEST_URL'}} # <-------

它与 frameworkVersion (>=1.1.0 <2.0.0) 一起正常工作。

从另一个文件获取数据的新方法是什么?

这是一种从另一个文件获取数据的新方法

environment:
    TEST_URL: ${file(./env.yml):${self:provider.stage}.TEST_URL}