-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Currently variables configuration is setup as limited two-phase resolution. Where in first phase we resolve some strict set of variables (crucial for some variable resolvers), and immediately afterwards follow with all others.
What's problematic both phases happen after some configuration was already consumed (e.g. plugins loaded, package configuration copied), therefore some parts of a configuration cannot e.g. be secluded to outer files, as it won't be resolved on time (see #7203).
Probably best method would be to resolve variables with following phases:
- Right after first read of config. Resolve
fileandselfresolvers (which do not depend on other resolvers). (JSfileresolvers may take some meta input, e.g. CLI params, as proposed here: Variables: Pass CLI params to JS file resolvers #4143) - Ensure environment variables are resolved from
.envfiles (upcoming with Support loading env variables from .env files #7907) - Resolve
envand remainingfileselfresolvers (which do not depend on other resolvers) - Initialize Serverless instance with registered plugins
- For each variable resolver ensure properties it depends on are fully resolved (e.g. resolvers that reach out to AWS services, demand
region,profileandcredentialsbe fully resolved for it to work) - Resolve all remaining variables
This should be achieved together with process flow refactor and will most likely mean a near complete rewrite of variables resolution logic
Other variable resolution issues that should be addressed when refactoring:
- Overwriting variable resolution require string fallbacks to be fully resolvable #7435 Fallbacks are resolved also when not used
- For some core properties (e.g.
providerandplugins) variables are not resolved as expected #7207 Variable that self references causes deploy to hang - File variable resolution happens before properties it depends on are resolved #7895 File variable resolution happens before properties it depends on are resolved