Base configuration for multiple resources


I am attempting to consolidate the boiler plate code that dozens of our aws api gateway resources share. E.g., all of them require a common set of RequestParameters and Integration RequestParameters, including the “Authorization” and “Accept” headers.

I am now looking for a way to move the common RequestParameters into a shared set of statements (I’d prefer a separate file, but a custom variable in the base serverless.yml would be fine as well), and include these in my resource definitions (which are located in separate files as well). Many of my resources require additional RequestParameters.

There are a number of questions similar to this one, covering merging of maps, and including files. However, I have not found a solution yet. Merging maps using “<<:” is possible; however, I currently fail to “read a file” in this place, or re-use a shared variable from the main serverless.yml. The serverless variable resolution allows a “${file(…)}” variable, but that seems to be evaluated after reading each file using js-yaml.

How do you create shared/base configurations for API gateway methods?

Some people seem to use a preprocessor. Is that really necessary or suggested? What preprocessors do you recommend?