Brightspace / serverless-plugin-for-each

Serverless plugin that adds $forEach syntax to reduce code duplication and allow creating dynamic templates
Apache License 2.0
1 stars 5 forks source link

Foreach.value inside $file issue #65

Closed cachila closed 1 year ago

cachila commented 1 year ago

Hello, I'm having an issue with using forEach.value inside a $file. This error pops-up

Cannot resolve serverless.yml: Variables resolution errored with:
  - Variable syntax error at "stepFunctions.stateMachines.$forEach_stepFunctions.template.$forEach.key.definition": Invalid variable type at index 35 in "${file(step-function-definitions/${forEach.value})}"
    $forEach_stepFunctions:
      iterator: 
        ${self:custom.stepFunctionIterator}
      template:
        $forEach.key:
          name: $forEach.key
          definition: ${file(step-function-definitions/${forEach.value})}

Any idea how to fix this?

Thanks!

AntonBazhal commented 1 year ago

Hi, serverless does variable resolution before calling any plugins, so it's impossible to generate serverless variable dynamically.