Similar to long standing region/stage and new profile preresolve.
test uses the service definition instead of `getCredentials` because
`getCredentials` is much more complex than `getStage`/`getProfile`/`getRegion`
and we only need to test that the config is updated, not all the
credential setting logic
Currently @ is not a valid variable character, so it doesn't get parsed
as one.
When it does get parsed, @ is not considered valid as part of a file path
- we add a blacklist as per https://github.com/serverless/serverless/pull/4528 to
handle this case.
If an override comes back as a variable containing a deep variable (e.g. `''${self:custom.${deep:1}, "fallback"}''`) or really any variable at all, it needs to be made a deep variable and paused for next iteration. Do this generally rather than only in the case of deep variables. See the test case for a circumstance that the prior fix didn't resolve. This more generalized handling improves the fix and solves a remaining issue we found locally.
Use the variable string from which the overwrite parameters were extracted as the replacement target (in the case of deep variable discovery) rather than the context property which represents the entire original value that the replacement is being waited upon. That context property can contain far more content than the overwrite string itself.
This avoids taking a deep value as a valid term within an overwrite
(defaulting) variable statement that will later resolve to undefined
but, as a deep variable string, is valid in immediate evaluation.
Fixes#5027
Use the variable syntax present in the given variable string, extracting it from the given string that may contain embedded custom variables (i.e. `${{self:var.${{self:var.foo}}.bar}}`).
Handle `self:service.[...]` references properly. The prior represents what the user typed into their configuration. In service, we move all this from `service` to `serviceObject`, therefore, by rewriting `self:service.[...]` to `self:serviceObject.[...]` user's will get the result they expect.
Use else if, given exclusivity of conditions