【问题标题】:Serverless variable from external file nested property来自外部文件嵌套属性的无服务器变量
【发布时间】:2018-11-22 13:13:30
【问题描述】:

我有无服务器 yml 和一个配置文件

配置文件

 app: {
   port: 3000,

 db: {
   connectionString: 'xxxxx'
 },
  lambdaDeploy:{
   stage : "DEV",
   region : "es-west-1"
 }

尝试在 yml 中使用这些变量,如下所示

yml

provider:
  name: aws
  runtime: nodejs6.10
  stage: ${file(./appconfiguration.json).app.stage}
  region: ${file(./appconfiguration.json).app.region}

但它的读取和默认设置

请指教。 谢谢

【问题讨论】:

    标签: node.js aws-lambda yaml aws-serverless


    【解决方案1】:

    这里使用的语法不正确。

    stage: ${file(./appconfiguration.json).app.stage}
    

    改用冒号:

    stage: ${file(./appconfiguration.json):app.stage}
    

    更多详情:https://www.serverless.com/framework/docs/providers/aws/guide/variables/#reference-variables-in-other-files

    【讨论】:

      猜你喜欢
      • 2013-02-06
      • 1970-01-01
      • 2020-11-09
      • 1970-01-01
      • 2011-09-06
      • 2012-04-08
      • 1970-01-01
      • 1970-01-01
      • 2022-11-03
      相关资源
      最近更新 更多