nopik / serverless-lambda-prune-plugin Goto Github PK
View Code? Open in Web Editor NEWDelete old versions of AWS lambdas from your account
Delete old versions of AWS lambdas from your account
In my opinion this plugin should run right after an sls function deploy
to prune the just deployed Lambda. I'm not a big fan that it touches Lambdas that aren't part of the current project/component. In fact, I would suggest to even remove that to avoid accidental deletions.
With the new plugin framework this should be easy to achieve. Let me know if I can help.
Will this plugin made available for Serverless v1.x also?
Currently the Prune plugin deletes older versions of Lambdas outside of my project (as per the documentation). It would be beneficial to be able to specify a specific function which to remove older versions from. We might not always want to remove "older" functions not associated with a Serverless project, because they might be used by other, non-serverless applications.
This plugin doesn't seem to work with latest serverless v0.5.0.
/node_modules/bluebird/js/release/async.js:49
fn = function () { throw arg; };
^
TypeError: Path must be a string. Received undefined
at assertPath (path.js:8:11)
at Object.posix.join (path.js:479:5)
When working with different people/teams in an AWS account it is not very helpful to have account wide pruning only.
Imagine some developers doing experiments on a test project (where lots of old test lambdas can remain) a project wide pruning would be very helpful.
The prune plugin should only prune functions contained in the active project by default, but when started with --all or --account prune everything everywhere.
After installing the function in my project root via npm install serverless-lambda-prune-plugin
i do run
sls function prune
and get the following error:
ServerlessError: In the command you just typed, the "function" is valid but "prune" is not.
What am i doing wrong?
Here is the full error:
/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:61
fn = function () { throw arg; };
^
ServerlessError: In the command you just typed, the "function" is valid but "prune" is not. Enter "serverless help" to see the actions for this context.
at new ServerlessError (/usr/local/lib/node_modules/serverless/lib/Error.js:17:11)
at Serverless.command (/usr/local/lib/node_modules/serverless/lib/Serverless.js:363:31)
at /usr/local/lib/node_modules/serverless/bin/serverless:19:16
at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
at Object.<anonymous> (/usr/local/lib/node_modules/serverless/bin/serverless:18:4)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:134:18)
at node.js:962:3
I am running serverless v 0.5.5
With the changes to Serverless 0.1.x this doesn't work out-of-the-box anymore. However, I could easily fix this by changing the last few lines of index.js
from this:
return this.S.validateProject()
.bind(_this)
.then(function() {
return _this.evt;
})
.then(_this._listLambdas);
to this:
return _this._listLambdas(_this.evt);
My understanding is that this should work perfectly fine. I can do a pull request if you like though I wasn't sure if I missed something.
I've been using Serverless 1.8.0 for a few months now and I tried installing [email protected] according to the readme but sls function prune
just prints
Command "prune" not found, Run "serverless help" for a list of all available commands.
Any suggestions?
Installed plugin in project root and updated s-project.json to reference the plugin. Then:
$ sls function prune
{ [ConfigError: Missing region in config]
cause:
{ [ConfigError: Missing region in config]
message: 'Missing region in config',
code: 'ConfigError',
time: Fri Jan 15 2016 13:02:32 GMT-0800 (PST) },
isOperational: true,
code: 'ConfigError',
time: Fri Jan 15 2016 13:02:32 GMT-0800 (PST) }
I see that the region can be overridden with an AWS_REGION environment variable, but if I set that, there are more issues. It seems like there is an issue in referencing the correct configuration:
AWS_REGION=us-west-1 sls function prune
{ [TimeoutError: Missing credentials in config]
cause:
{ [TimeoutError: Missing credentials in config]
message: 'Missing credentials in config',
code: 'CredentialsError',
time: Fri Jan 15 2016 13:05:15 GMT-0800 (PST),
originalError:
{ message: 'Could not load credentials from any providers',
code: 'CredentialsError',
time: Fri Jan 15 2016 13:05:15 GMT-0800 (PST),
originalError: [Object] } },
isOperational: true,
code: 'CredentialsError',
time: Fri Jan 15 2016 13:05:15 GMT-0800 (PST),
originalError:
{ message: 'Could not load credentials from any providers',
code: 'CredentialsError',
time: Fri Jan 15 2016 13:05:15 GMT-0800 (PST),
originalError:
{ message: 'Connection timed out after 1000ms',
code: 'TimeoutError',
time: Fri Jan 15 2016 13:05:15 GMT-0800 (PST) } } }
Ease of use enhancement:
Having two aws-profiles in my .aws/credentials
Serverless normally takes the one specified in ./admin.env/
. But tis plugin does not use this profile but takes the default one.
My .aws/credentials
look as follows:
[default]
aws_access_key_id = ***
aws_secret_access_key = ***
[serverless]
aws_access_key_id = ***
aws_secret_access_key = ***
region = eu-central-1
I have several profiles in my ~/.aws/credentials
file. I'd like to select one to use with this plugin. How can I do that?
Thanks.
Every time I run the plugin, it starts pruning but shortly after I get Unhandled rejection TooManyRequestsException: Rate exceeded
which causes it to crash. I can run it over an over, but I only get a handful of successful deletions out of i.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.