We're making use of the great feature for breaking up serverless.yml file where you can have the resources be a list.
With this input:
serverless.yml
service: example
provider:
name: aws
resources:
- ${file(resources-1.yml)}
- ${file(resources-null.yml)}
resources-1.yml
Resources:
test:
Type: AWS::SQS::Queue
resources-null.yml
# We will add resources here at some point in the future
Resources:
The resulting .serverless/cloudformation-template-update-stack.json is missing the test resource from resources-1.yml. There is no error reported.
If we fix resources-null.yml to have an object:
resources-null.yml
# We will add resources here at some point in the future
Resources: {}
then the resulting .serverless/cloudformation-template-update-stack.json has the test resources as expected.
SLS_DEBUG='*' sls package output
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Load command dev
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Packaging service...
Serverless: Invoke aws:package:finalize
Serverless: Invoke aws:common:moveArtifactsToPackage
Installed version
% serverless --version
Framework Core: 1.78.1
Plugin: 3.7.0
SDK: 2.3.1
Components: 2.34.5
It's possible that this would be resolved by #8014 but I think it would be more helpful to simply exclude any null Resources when processing the list, as tracking down the offending source file might be tricky.
I believe that this is happening here but am not yet sure what a good approach might be to get the behaviour I'd like. The mergeArrays function already discards null values from the list, but what's happening appears to be that it's trying to merge { "Resources": null } with the existing object and getting null as an output.
Any thoughts? I recognize that ultimately it's the way that we've got Resources with a null value that is at fault, but it would have been extremely helpful if the framework could have identified this as a problem.
We're making use of the great feature for breaking up
serverless.ymlfile where you can have theresourcesbe a list.With this input:
serverless.ymlresources-1.ymlresources-null.ymlThe resulting
.serverless/cloudformation-template-update-stack.jsonis missing thetestresource fromresources-1.yml. There is no error reported.If we fix
resources-null.ymlto have an object:resources-null.ymlthen the resulting
.serverless/cloudformation-template-update-stack.jsonhas thetestresources as expected.SLS_DEBUG='*' sls packageoutputInstalled version
It's possible that this would be resolved by #8014 but I think it would be more helpful to simply exclude any
nullResourceswhen processing the list, as tracking down the offending source file might be tricky.I believe that this is happening here but am not yet sure what a good approach might be to get the behaviour I'd like. The
mergeArraysfunction already discardsnullvalues from the list, but what's happening appears to be that it's trying to merge{ "Resources": null }with the existing object and gettingnullas an output.Any thoughts? I recognize that ultimately it's the way that we've got
Resourceswith anullvalue that is at fault, but it would have been extremely helpful if the framework could have identified this as a problem.