Help with creating a serverless plugin

I am trying to make a plugin that adds functions and layers automatically to the serverless config at compilation, so the plugin currently hooks at:


What would be the very first hook?
Where could one find a list of hooks and the order at which they fire?
Currently I am adding the configurations to the serverless object at compilation.

const configInput = this.serverless.configurationInput;

let initLayers = configInput.layers ? configInput.layers : {};
// Theres a loop here but I omitted it to avoid clutter, the loop adds layers to initLayers
// At the end of the loop this gets assigned with multiple layer objects
configInput.layers = initLayers;

This does not seem to work, but when I add the functions and layers to other properties of this.serverless, it does work and deploy just fine, but has issues.

What would be the correct way to add configurations to the initial serverless configuration in order to make serverless do the compilation of resources correctly?

Adding the functions and layers to other properties like:




Seems to make serverless package the code and layers just fine, but throws an error, when I try to serverless invoke -f name :

Function name doesn’t exist in this service!

I found like 5 different properties that have the functions and layers properties, I dont know which one of them should be set in order to correctly make serverless compile this config.

Help much appreciated!

Update: It seems that adding function configuration objects to this.serverless.service.functions makes the framework package the code correctly and produces artifacts in the .serverless folder

Update2: Adding layers and functions to:


seems to produce the correct behavior, but serverless invoke still doesnt work…
Is that because the functions are not hard-coded into the config, but rather get added on compilation?
If I test the functions through the AWS console, or click the APIGW endpoints, it does invoke the function correctly, which means serverless compiled everything successfully and it works,
But not serverless invoke…