Resolves matter 1 of https://github.com/serverless/serverless/issues/1895 Allow each function to declare the ARN of the role that it is to execute within. If any function has no role ARN but provider role ARN is defined then use that role for such functions. If any function does not have a specified role (even by falling back to a provider-wide role) then add the default policy and role so that it can be used for such functions. Break out the portions of the logic into their discrete units so that the plugin code is a readable summary. Add comments to the discrete units. Add tests that check that the default role and policy are not added if every function has a role. Add tests that check that every function that has a declared role gets it assigned. Add tests that check that every function that has no declared role but where a provider role is declared gets the provider role assigned.
Compile Functions
This plugins compiles the functions in serverless.yml to corresponding lambda CloudFormation resources.
How it works
Compile Functions hooks into the deploy:compileFunctions lifecycle.
It loops over all functions which are defined in serverless.yml.
Inside the function loop it creates corresponding CloudFormation lambda function resources based on the settings
(e.g. function name property or service defaults) which are provided in the serverless.yml file.
The function will be called <serviceName>-<stage>-<functionName> by default but you can specify an alternative name
with the help of the functions name property.
The functions MemorySize is set to 1024 and Timeout to 6. You can overwrite those defaults by setting
corresponding entries in the services provider or function property.
At the end all CloudFormation function resources are merged inside the compiled CloudFormation template.