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
It's unsafe operation, as it unconditionally merges all arrays and objects, producing broken configurations in some scenarios (e.g. merging two independent Fn::Joininstructions, as reported here #6569). Also it doesn't apply any validation so technically two resources of very different types, if they share logical id, will be merged silently.
Proposal for new approach
Restrict resources for CF Resources section.
Accept newly introduced user resources (not extensions) at resources.additions. Use direct (Object.assign like) assignment to apply them on Resources, but error if given resource was already generated by the framework (do not silently override)
(Already implemented at feat: Support resource extensions #7352) Accept extensions at resources.extensions for definition of resource extensions which should be applied to resources already generated by the framework. It should be intelligent (deterministic) in sense that:
Properties should be merged flat way (so framework generated given property is listed, it'll be overriden by user resource completely)
DependsOn should include both items, those listed by framework, and those indicated by user
Support addition of other CloudFormation template properties at top level cloudFormationAdditions, where each property should be supported individually as follows:
description - Assign as is to result template
metadata - Assign each section directly, but error if metadata of given name already exists
parameters - Assign each definition directly, but error if parameter of given name already exists
mappings - Assign each mapping directly, but error if mapping of given name already exists
conditions - Assign each condition directly, but error if condition of given name already exists
transform - Add listed macros to the list, but prevent the duplicates
outputs - Assign each output directly, but error if output of given name already exists
Above can be implemented without breaking current behavior. Ideally after having that in, we should mark current behavior as deprecated.
PR's welcome (each section can be tackled individually with different PR)
Currently after all resources are generated, ones specified by user (defined at
resources.Resources) are deeply merged to it:serverless/lib/plugins/aws/package/lib/mergeCustomProviderResources.js
Lines 15 to 18 in 66ef74b
It's unsafe operation, as it unconditionally merges all arrays and objects, producing broken configurations in some scenarios (e.g. merging two independent
Fn::Joininstructions, as reported here #6569). Also it doesn't apply any validation so technically two resources of very different types, if they share logical id, will be merged silently.Proposal for new approach
resourcesfor CFResourcessection.resources.additions. Use direct (Object.assignlike) assignment to apply them onResources, but error if given resource was already generated by the framework (do not silently override)resources.extensionsfor definition of resource extensions which should be applied to resources already generated by the framework. It should be intelligent (deterministic) in sense that:Propertiesshould be merged flat way (so framework generated given property is listed, it'll be overriden by user resource completely)DependsOnshould include both items, those listed by framework, and those indicated by usercloudFormationAdditions, where each property should be supported individually as follows:description- Assign as is to result templatemetadata- Assign each section directly, but error if metadata of given name already existsparameters- Assign each definition directly, but error if parameter of given name already existsmappings- Assign each mapping directly, but error if mapping of given name already existsconditions- Assign each condition directly, but error if condition of given name already existstransform- Add listed macros to the list, but prevent the duplicatesoutputs- Assign each output directly, but error if output of given name already existsAbove can be implemented without breaking current behavior. Ideally after having that in, we should mark current behavior as deprecated.
PR's welcome (each section can be tackled individually with different PR)