Lifecycle hook for adding custom resources?

Which is the proper lifecycle hook for adding custom resources to a service? I’ve noticed many plugins do this in the deploy:deploy hook, this seems to me to be much too late. Doesn’t packaging happen before deploy?

If you are talking about adding custom CloudFormation resources, before:package:finalize is a good spot.

If you are talking about adding files/assets/etc to the serverless zip file, then after:package:initialize or maybe before:package:setupProviderConfiguration

1 Like

I too was confused in the beginning about where to hook plugins into the serverless lifecycle. So I made a simple plugin that bound to every event and printed out where it was.

Code and log is here:

1 Like

This is really great, thanks for sharing. I guess it’s not completely obvious what is happening at each of these hooks, but it sure does help.