agutoli / serverless-layers

Serverless.js plugin implementing AWS Lambda Layers, reducing lambda size, warm-up, and deployment time.
MIT License
229 stars 54 forks source link

Incompatible with dynamic deployment buckets #70

Open tstackhouse opened 3 years ago

tstackhouse commented 3 years ago

If no deployment bucket is configured, sls deploy will create a bucket dynamically, but this plugin does not pick up that bucket name and instead fails the entire deploy. This plugin would be very useful to package node_modules as a dedicated layer and slim down individual function packages.

AxopenLyon commented 2 years ago

I'd really love to see this feature. As is it right now, I can't use this plugin, as it would mean creating a S3 bucket beforehands, which is not the purpose of IaC.

Would it be a possibility to see this feature in the future ?

Rayyan98 commented 1 year ago

Does anyone have a workaround for this

tstackhouse commented 1 year ago

I've been using this with the Deployment Bucket plugin, so that I'm not dynamically creating the deployment bucket, but it's still managed with serverless. The only downside for this is after doing sls remove, I have to manually (or have a CI script) empty and remove the deployment buicket.

Rayyan98 commented 1 year ago

I would appreciate if this plugin exposed some hooks for me to use, but ig i'll use the same plugin as well

agutoli commented 1 year ago

It is not something I'm planning to support/fix very soon, honestly. It would need a big refactoring which I can't do currently. https://github.com/agutoli/serverless-layers/issues/116

agutoli commented 1 year ago

I would appreciate if this plugin exposed some hooks for me to use, but ig i'll use the same plugin as well

What kind of hooks do you need?

Rayyan98 commented 1 year ago

If the serverless-layers package can implement a lifecycle named deployLayer then serverless will auto generate a hook for me called before:deployLayer, then I can write a short plugin as a small js file which integrates in my serverless file, reads the layersDeploymentBucket name from custom and creates the bucket / ensures the bucket is created, before the serverless-layers plugin takes over. I would prefer this over integrating the plugin @tstackhouse mentioned because

  1. It is explicit control over execution flow,
  2. The small js file is very explicit about what it does and any developer that comes after me will be able to figure out why its necessary and they can safely remove it when serverless-layers plugin itself implements #116

I also created an issue for this here #132