Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using variablesResolutionMode: 20210219 prevents loading external configuration files outside of service folder #9141

Closed
laurynas-karvelis opened this issue Mar 18, 2021 · 3 comments
Assignees

Comments

@laurynas-karvelis
Copy link

Hello,
First of all I wanted to thank everyone involved creating such a great tool!

After upgrading to the latest serverless version 2.30.3 and applying variablesResolutionMode: 20210219 to service serverless.yml in preparation for serverless@v3 causes serverless offline and serverless deploy invocations to throw following error(s) when trying to load configuration files sourced outside serverless main service folder:

Cannot resolve serverless.yml: Variables resolution errored with:
    - Cannot resolve variable at "custom.globals": Cannot load file from outside of service folder

Loading complementary config files from outside service folder usually is very helpful way for developers who maintain mono repos that contain number of individual serverless services where all or some share common configuration values used across the project. Preventing such possibility introduces unnecessary config duplication and unwanted future misconfigurations due to configs being out of sync.

I searched your repository for this error and found a check that causes this error here:

if (!filePath.startsWith(`${servicePath}${path.sep}`)) {
throw new ServerlessError(
'Cannot load file from outside of service folder',
'FILE_SOURCE_PATH_OUTSIDE_OF_SERVICE'
);
}

serverless.yml
service: service-name
variablesResolutionMode: 20210219

provider:
  name: aws
  lambdaHashingVersion: 20201221
  stage: local
custom:
  globals: ${file(../../serverless/globals.yml)}
//node_modules/.bin/serverless offline output
 Serverless Error ----------------------------------------
 
  Cannot resolve serverless.yml: Variables resolution errored with:
    - Cannot resolve variable at "custom.globals": Cannot load file from outside of service folder
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              12.20.1
     Framework Version:         2.30.3 (local)
     Plugin Version:            4.5.1
     SDK Version:               4.2.0
     Components Version:        3.7.5
 
error Command failed with exit code 1.

Installed version

Framework Core: 2.30.3 (local)
Plugin: 4.5.1
SDK: 4.2.0
Components: 3.7.5
@laurynas-karvelis laurynas-karvelis changed the title Using variablesResolutionMode: 20210219 prevents loading external configuration files outside of servie folder Using variablesResolutionMode: 20210219 prevents loading external configuration files outside of service folder Mar 18, 2021
@medikoo
Copy link
Contributor

medikoo commented Mar 18, 2021

@laurynas-karvelis great thanks for report!

Can we consider this as duplicate of #9095 ?

@laurynas-karvelis
Copy link
Author

By looking at the ticket you linked it is indeed the same issue. Thanks for such quick response @medikoo!

@medikoo
Copy link
Contributor

medikoo commented Mar 18, 2021

Thanks for confirmation.

I'm closing this as duplicate then

@medikoo medikoo closed this as completed Mar 18, 2021
This was referenced Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants