brendtumi / ec2-spot-notification Goto Github PK
View Code? Open in Web Editor NEWAWS EC2 Spot Instance Termination Notices for NodeJs
License: MIT License
AWS EC2 Spot Instance Termination Notices for NodeJs
License: MIT License
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-instance-termination-notices.html
This item is maintained for backward compatibility; you should use instance-action instead.
It seems like it is maintained, without any plans of deprecation that I can see, but might be a good idea to get ahead and use the new method instead.
It might be good to have a debug flag or use winston to do some logging so its easier to debug and be notified when its going into a terminating state.
Probably good to do a warning level info when terminating - and verbose level when doing a 5 second check.
New in March '22: https://aws.amazon.com/about-aws/whats-new/2022/03/amazon-ec2-auto-scaling-lifecycle-instance-metadata/
https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks.html
Would be good to handle these same state changes here - to be notified if a instance is dying not because of a spot being killed, but because the instance is going down. I don't think it makes sense to have a different node module for this?
I have found this error in my logs:
TypeError: Cannot read properties of undefined (reading 'statusCode')
at Request._callback (/usr/src/app/node_modules/ec2-spot-notification/lib/index.js:87:35)
This corresponds to this code:
request.get("spot/termination-time", SpotNotification.requestOpts, function (error, response, body) {
if (!error && response.statusCode === 200) {
// TODO: check value is date string or not
resolve(moment(body));
}
else if (response.statusCode === 404) { // HERE
resolve(null);
}
else {
reject(error || response.statusCode);
}
});
The code should check for error before accessing response.statusCode
There are a whole bunch of instance meta-data endpoints that are available. This system does one thing well, but I wonder if its worth also providing a query function so that the user can get the state of the other values (this already gets the ec2 instance identifier, why not allow other things?)
Full list here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-categories.html
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.