serverless / serverless-azure-functions

Serverless Azure Functions Plugin – Add Azure Functions support to the Serverless Framework
MIT License
266 stars 162 forks source link

Allow template content in serverless.yml #452

Open erikerikson opened 4 years ago

erikerikson commented 4 years ago

This is a Feature Proposal

TL;DR: allow the declaration of arbitrary Azure Resource Manager templates in the serverless.yml

Description

Please add support for declaring arbitrary ARM templates in serverless.yml files. The proposed mechanism is adding support for a template section. I am aware of the configuration at provider.armTemplate.file and provider.armTemplate.parameters but while it appears to allow users to supply a single external template and parameters to it, it does not appear to support the declaration of template contents within the serverless.* files.

This would enable complete system declaration using the Serverless Framework. As is we must split non-function or APIM resources into a separate files. Making the requested change would provide a richer, cleaner variable capability that could be enriched for Azure (e.g. blob storage, key vault, et cetera) and a more friendly, compact, consistent developer experience. The end result is the distillation of the system structure and bringing that to the forefront of engineer attention thus reducing cognitive load and the noise filtering requirements on your customers.

service: my-service
provider:
  name: azure
[...]
plugins:
  - serverless-azure-functions
[...]
template:
  parameters:
    [...]
  variables:
    [...]
  resources: 
   - [...]
  outputs:
    [...]

It should be possible and legible to load any linked file (at provider.armTemplate.file) and merge the contents of template over top of that and finally add the declared function resources.

Similar or dependent issues:

erikerikson commented 4 years ago

FYI, docs for provider.armTemplate.file and provider.armTemplate.parameters added by https://github.com/serverless/serverless/pull/7672 and pending addition via https://github.com/serverless/serverless/pull/7698

erikerikson commented 4 years ago

Is this something that the committers to this repository are at all open to merging support for?

It clearly could be made to work using the provider.armTemplate attribute. However, in the AWS context I became very used to declaring the entirety of independent services (or subsystems in larger service cases) in a single file and strongly prefer not having to change context by switching panes when making changes to tightly related assets.

erikerikson commented 4 years ago

Paging @tbarlow12 - you've contributed often and recently. Opinion?