Serverless: Importing file to custom + other variables

Viewed 438

I have a serverless.common.yml, with properties that should be shared by all the services, with that:

service: ixxxx
custom:
  stage: ${opt:stage, self:provider.stage}
  resourcesStages:
    prod: prod
    dev: dev
  resourcesStage: ${self:custom.resourcesStages.${self:custom.stage}, self:custom.resourcesStages.dev}

lambdaPolicyXRay:
  Effect: Allow
  Action:
    - xray:PutTraceSegments
    - xray:PutTelemetryRecords
  Resource: "*"

And, another serverless.yml inside a services folder, which uses properties on the common file:

...

custom: ${file(../../serverless.common.yml):custom}
...
environment:
    stage: ${self:custom.stage}
...

In that way, I can access the custom variables (from the common file) without a problem. Now, I want to continue to import this file to custom, but adding new variables, related to this service, to it, so I tried that:

custom: 
  common: ${file(../../serverless.common.yml):custom}
  wsgi:
    app: app.app
    packRequirements: false
  pythonRequirements:
    dockerizePip: non-linux

And it seems it's possible to access, for example:

environment:
    stage: ${self:custom.common.stage}

But now, I'm receiving the error:

 Serverless Warning --------------------------------------

  A valid service attribute to satisfy the declaration 'self:custom.stage' could not be found.


 Serverless Warning --------------------------------------

  A valid service attribute to satisfy the declaration 'self:custom.stage' could not be found.


  Serverless Error ---------------------------------------

  Trying to populate non string value into a string for variable ${self:custom.stage}. Please make sure the value of the property is a strin

What am I doing wrong?

0 Answers
Related