Logging solution for aws spot instances - amazon-web-services

Is there any solution or way, which can help me to get live/real-time logs?
I have 100s of Spot instances that come and go frequently, So we need to configure a setup that captures the logs despite this spot life cycle, which means whenever new spot instance launches we will get the respective instance to log immediately.
please help/suggested the way.

Related

How do I manage AWS spot instances in a way that is cost efficient?

I am new to AWS and still getting the hang of coding with the API they provide.
What I'm essentially doing right now is to launch a spot instance and connect provisioned volume, and whenever a 2-minute termination notice arrives, launch a new spot instance and attach that volume while canceling the previous spot request.
My concern for this method is whether this is cost-efficient, or am I just wasting more money by attaching provisioned volume? If anyone has a better way of managing their spot instances with fault-free method I would be grateful if you could share some thoughts.

Auto Delete Stack on Instance Termination

I am currently working with EC2 instances and have made a Java CLI tool to quickly launch/kill instances for our developers. One of the options is to set a lease time, so that the instance terminates after a certain amount of hours. For spot instances this works great, terminates the instance, the request, and deletes all volumes associated with that instance.
However, for on demand instances, the lease time only affects instance termination and does not delete the stack that it was on.
Is there some way to automate this through AWS? I don't want to write a script to manually check or even monitor, it would be great if this could be automated through AWS itself. I have looked and have not found anything. Any advice is appreciated!

monitor ec2 instances lifecycle

Hi I am new to AWS and I started learning now. In my environment I noticed all the issues are getting raised by autoscaling only. Whenever new instances comes up there are some small issues happening in environment. So I thought if we have a script to trigger a alert whenever any ec2 instance get reboots or terminates or any new instance spins up but I do not have a idea how to achieve it.
While checking with AWS support they are pointing cloudwatch where we need to trigger alarm for each instance. When we have huge number of instances and multiple environments, setting up a alarm for individual instance is hectic job. Can anyone suggest how can I get information about a instance reboot, termination and new instance spin up. Thanks in advance.
You can create SNS notification whenever auto scaling scales.
Read AWS documentation
You can write your script in your favourite language which can subscribe to the particular SNS topic.

Amazon AWS EC2 instance relaunches when terminated

I have an instance that I have never actually launched myself that tends to start each time once I terminate it. This is annoying, as I would need to pay for it and customer service does not reply. Had anyone got a similar question before?
With the aid of help of the Amazon Support the problem was resolved. It appears that is you have an instance constantly appearing after being terminated and you have no active Autoscale groups, you should cancel it via the new Spot console (beta, the one you access via "Try it out" button), as most likely it is the fleet instance. I'll leave it here in case it is helpful to the others having the same issue.

EC2 Spot instances: How to start tasks, how to stop them?

I have a long batch job that I'd like to run on AWS EC2 Spot Instances, to save money. However, I can't find the answer to two seemingly critical questions:
When a new instance is created, I need to upload the code onto it, configure it, and run the code. How does that get done for Spot Instances, which are created automatically and unattatendly?
When an instance is stopped, I would prefer having some type of notification, so that the state could be saved. (This is not critical, as the batch job will run fine if terminated suddenly - but a clean shutdown is preferred).
What is the standard way to deploy spot instances? Is there a way to do manual setup, turn it into a spot instance, and then let it hibernate until the spot price is available?
As to #1, if you create an AMI (amazon machine image), you can have everything you want pre-installed on a 'hibernating' image that you can use as a basis for the spot image you start:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances-getting-started.html
For #2, you can be notified when a spot instance terminates using SNS:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-autoscaling-notifications.html
http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/ASGettingNotifications.html
BTW: You can be notified the the instance was terminated, but only after it terminates. You can't get notified that an instance is about to be shutdown and gracefully save the state - you need to engineer your solution to be OK with unexpected shutdowns.
No matter how high you bid, there is always a risk that your Spot
Instance will be interrupted. We strongly recommend against bidding
above the On-Demand price or using Spot for applications that cannot
tolerate interruptions.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-protect-interruptions.html
You can use the user data settings to download from a specific repository a script and run it at the first instance startup.
As E.J. Brennan said: you can use SNS