henhal / serverless-plugin-layer-manager

Plugin for the Serverless framework that offers improved AWS Lambda layer management
MIT License
12 stars 8 forks source link

Feature: Use --unsafe-perm to allow to run post/pre install scripts #17

Closed ccruz2886 closed 1 year ago

ccruz2886 commented 1 year ago

I'm having issues installing the packages for the layers because cannot run the preinstall and post install scripts, due missing --unsafe-perm flag, which is need to run them.

This PR introduces a new custom field which follows a convention base on the layer name within the layerManager plugin. i.e.

custom: 
  plugin:
    layerManager:
      [layer key name]:
        unsafePermissions: true

complete example.

custom:
  plugin:
    layerManager:
      [layer name]:
        unsafePermissions: true
...

layers:
  [layer name]:
    path: pathToLayer
    description: Node Layers
henhal commented 1 year ago

Thanks for the PR @ccruz2886! I'm happy to merge this, however could you remove the line in README.md about this being forked, since that line does not apply upstream?

I have a nitpick comment as well, but I'll let you decide if you'll bother addressing it: unSafePermissions should really be unsafePermissions in correct English since "unsafe" is one word, not two.

ccruz2886 commented 1 year ago

Hi @henhal addressed your comment feedback, appreciate your response 😄

henhal commented 1 year ago

Thanks @ccruz2886, released as 1.1.1!

scott-barta commented 1 year ago

FYI, I had a build which started failing because it depended on this plugin, and it didn't have a version pin so it started picking up the change immediately from main. Exception is below. If anyone else is seeing this, I solved it by pinning to v1.0.6 of the plugin, which works for me since it doesn't seem I need the feature it's adding:

serverless plugin install --name serverless-plugin-layer-manager@1.0.6

The exception:

Error:
TypeError: Cannot read properties of undefined (reading 'unsafePermissions')
    at LayerManagerPlugin.installLayer (/github/workspace/node_modules/serverless-plugin-layer-manager/LayerManagerPlugin.js:68:30)
    at /github/workspace/node_modules/serverless-plugin-layer-manager/LayerManagerPlugin.js:96:21
    at Array.filter (<anonymous>)
    at LayerManagerPlugin.installLayers (/github/workspace/node_modules/serverless-plugin-layer-manager/LayerManagerPlugin.js:91:8)
    at package:initialize (/github/workspace/node_modules/serverless-plugin-layer-manager/LayerManagerPlugin.js:53:14)
    at PluginManager.runHooks (/github/workspace/node_modules/serverless/lib/classes/plugin-manager.js:530:15)
    at async PluginManager.invoke (/github/workspace/node_modules/serverless/lib/classes/plugin-manager.js:564:9)
    at async PluginManager.spawn (/github/workspace/node_modules/serverless/lib/classes/plugin-manager.js:585:5)
    at async before:deploy:deploy (/github/workspace/node_modules/serverless/lib/plugins/deploy.js:40:11)
    at async PluginManager.runHooks (/github/workspace/node_modules/serverless/lib/classes/plugin-manager.js:[53](https://github.com/Blended-Technologies/monorepo/actions/runs/5326954838/jobs/9649689889#step:7:54)0:9)
    at async PluginManager.invoke (/github/workspace/node_modules/serverless/lib/classes/plugin-manager.js:563:9)
    at async PluginManager.run (/github/workspace/node_modules/serverless/lib/classes/plugin-manager.js:604:7)
    at async Serverless.run (/github/workspace/node_modules/serverless/lib/serverless.js:174:5)
    at async /github/workspace/node_modules/serverless/scripts/serverless.js:771:9