I have two sets of routes, one group all prefixed with /admin
and one all prefixed with /customer
. All of the admin routes use the same authorization and have cors set to true. Same with the customer routes, all use the same authorization Cognito group and have cors set to true. Is there a way to nest these definitions so I don’t have to keep repeating these settings common to a group of routes?
I don’t think there’s any way to nest. The serverless.yml
is a regular YAML file so you can probably use anchors to duplicate/inherit properties.
admin_settings: &admin_settings
cors: true
authorizer: admin_authorizer
customer_settings: &customer_settings
cors: true
authorizer: customer_authorizer
functions:
admin_func1:
<<: *admin_settings
handler: admin.func1
admin_func2:
<<: *admin_settings
handler: admin.func2
customer_func1:
<<: *customer_settings
handler: customer.func1
customer_func2:
<<: *customer_settings
handler: customer.func2
I’ve done something similar with environment variables but never with function handlers.