You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serverless 2.3.0 and higher does not always resolve nested variables correctly. Presumably Serverless supports nested variables, as they are mentioned in Serverless' documentation, and resolved correctly prior to v2.3.0.
The example below is a version of the aws-nodejs template (ie what is created when running serverless create --template aws-nodejs) modified to include a nested variable to define provider.region. provider.region is then used to provide an environment variable to the handler. The handler code is modified to emit the provided environment variable.
As the examples demonstrate, in serverless v2.2.0 and below, the region is correctly interpreted from the yml config and passed into the handler. In 2.3.0 and higher, the region is not correctly interpreted, and instead a literal fragment of the nested variable is passed instead.
I believe this is due to a regex change that was introduced in v2.3.0 to address CloudFormation variable label collisions, which has had the inadvertent effect of breaking nested variable resolution. My belief that this is the issue is further reinforced by the fact if I revert the regex in question in any ^2.2.0 version of serverless, the problem goes away.
The text was updated successfully, but these errors were encountered:
logicalor
changed the title
In serverless versions 2.3.0 and higher, Resolution of Variable Variables is incomplete / broken
In serverless versions 2.3.0 and higher, Resolution of Nested Variables is incomplete / broken
Nov 9, 2020
Serverless 2.3.0 and higher does not always resolve nested variables correctly. Presumably Serverless supports nested variables, as they are mentioned in Serverless' documentation, and resolved correctly prior to v2.3.0.
The example below is a version of the aws-nodejs template (ie what is created when running
serverless create --template aws-nodejs
) modified to include a nested variable to defineprovider.region
.provider.region
is then used to provide an environment variable to the handler. The handler code is modified to emit the provided environment variable.As the examples demonstrate, in serverless v2.2.0 and below, the region is correctly interpreted from the yml config and passed into the handler. In 2.3.0 and higher, the region is not correctly interpreted, and instead a literal fragment of the nested variable is passed instead.
I believe this is due to a regex change that was introduced in v2.3.0 to address CloudFormation variable label collisions, which has had the inadvertent effect of breaking nested variable resolution. My belief that this is the issue is further reinforced by the fact if I revert the regex in question in any ^2.2.0 version of serverless, the problem goes away.
serverless.yml
handler.js
(serverless v2.2.0) serverless invoke local -f hello --data {}
output(serverless ^v2.2.0) serverless invoke local -f hello --data {}
outputInstalled version
The text was updated successfully, but these errors were encountered: