Variables resolver deprecation: Cannot load file from outside of service folder

I currently have the following in my serverless.yml file which has been working just fine:

custom:
  webpack: ${file(../../../shared/services/webpack.config.yml)}

But after upgrading Serverless version to 2.28.0, I now see the following deprecation warning:

Serverless: Deprecation warning: Variables resolver reports following resolution errors:
              - Cannot resolve variable at "custom.webpack": Cannot load file from outside of service folder

Is this a new deliberate limitation of not being able to reference configuration files from ancestor directories, since I use that to share configuration between multiple serverless files in different code directory branches like the following:

aggregates
    - aggregate-A
        - libraries
            - ...
        - services
            - service-A1
                - serverless.yml
    - aggregate-B
        - libraries
            - ...
        - services
            - service-B1
                - serverless.yml
shared
    - services
        - webpack.config.yml

This allows me to group services by aggregate, but also have cross-cutting concerns outside that hierarchy.

Is this layout going to be broken in the future, or is there some way of still supporting this and removing the deprecation warning?

4 Likes

I have the same concern. Following the monorepo/multiple services approach described here: Share Code Between Services | Serverless Stack. What could be the workaround for this?

1 Like

I am also concerned about this, we are using a monorepo type structure with multiple microservices, each with their own serverless.yml. It doesn’t make sense to not be able to share variables between the projects.

Just ran into this issue. Looking for a way to fix this properly!

Please note that this is not removing support for external files. This was fixed in 2.28.2: Release 2.28.2 (2021-03-02) · serverless/serverless · GitHub

1 Like

I am just closing this topic so there is no more confusion