serverless / serverless

⚡ Serverless Framework – Use AWS Lambda and other managed cloud services to build apps that auto-scale, cost nothing when idle, and boast radically low maintenance.
https://serverless.com
MIT License
46.12k stars 5.68k forks source link

RESOLVER_RESOLVE_VARIABLE _ERROR #12471

Open gavinsui1106 opened 3 weeks ago

gavinsui1106 commented 3 weeks ago

Issue description

when i used sls4 to deploy my project,the RESOLVER_RESOLVE_VARIABLE_ERROR is happend in codebuild's log

command serverless deploy --stage {mystage} --param="division=${envDivision}"

serverless.yml ${self:custom.${opt:stage,self:provider.stage}.XXX} ${file(xxx/serverless_xxx${param:division}.yml)}

what's wrong with my command?

Context

when i used sls4 to deploy my project,the RESOLVER_RESOLVE_VARIABLE_ERROR is happend in codebuild's log

command serverless deploy --stage {mystage} --param="division=${envDivision}"

serverless.yml ${self:custom.${opt:stage,self:provider.stage}.XXX} ${file(xxx/serverless_xxx${param:division}.yml)}

what's wrong with my command?

gavinsui1106 commented 2 weeks ago

when i deleted the code "--param="division=${envDivision}"" , so that the deploy command is [serverless deploy --stage ${env}] then other error is happend. but when i use the same code in sls3, its successfully builded!!!

error message Failed to resolve variable 'custom.${opt:stage' with resolver 'config' :ERROR :Key "custom.${opt:stage" is not defined in config file.

here is my whole code

buildspec.yml

serverless deploy --stage ${env}
#${env} is set with environment during AWS's Coodebuild . for example ,Dev is the value of env.

serverless.yml

provider:
  name: test
  runtime: dotnet6
  region: XXX
  environment: ${file(slsconf/serverless_environment.yml)}

custom:
   ${file(slsconf/serverless_custom${opt: stage, self: provider.stage}.yml)}

slsconf/serverless_environment.yml

TZ: XXX
EnvironmentVariable1: ${self: custom.${opt: stage, self: provider.stage}.EnvironmentVariable1Val}
EnvironmentVariable2: ${self: custom.${opt: stage, self: provider.stage}.EnvironmentVariable2Val}

slsconf/serverless_customDev.yml

EnvironmentVariable1Val: XXX
EnvironmentVariable2Val: XXX
yeyeric commented 1 week ago

same here, was working great on serverless3 but from today it doesn't work on sls4 it seems the fallback strategy is broken

custom:
  is_async_task_enabled:
    production: true
    other: false
  final_is_async_task_enabled: ${self:custom.is_async_task_enabled.${self:provider.stage}, self:custom.is_async_task_enabled.other}

gives


Error: Failed to resolve variable 'custom.is_async_task_enabled.eric' with resolver 'config' and provider 'self': Error: Key "custom.is_async_task_enabled.eric" is not defined in config file
    at #resolveKey (file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:16542)
    at _ResolverManager.resolve (file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:21362)
    at #handlePlaceholderNode (file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:20310)
    at file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:18471
    at processNodeAndHandleCompletion (file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:137[27](https://gitlab.com/easygy/main/app/-/jobs/6920730129#L27))
    at processNodeAndManagePromise (file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:14363)
    at file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:14180
    at Array.forEach (<anonymous>)
    at processSinks (file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:14135)
    at processGraphInParallel (file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:13978)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async #resolveAndReplacePlaceholders (file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:18188)
    at async _ResolverManager.resolveAndReplacePlaceholdersInConfig (file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:17913)
    at async Object.resolveServiceConfig (file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:989:[28](https://gitlab.com/easygy/main/app/-/jobs/6920730129#L28)507)
    at async file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:992:1209
    at async route (file:///root/.serverless/releases/4.0.24/package/dist/sf-core.js:992:1182)```
gavinsui1106 commented 3 days ago

@yeyeric maybe this error is fixed in 4.0.30,but another error is happened.