Elastic Beanstalk terminates my EC2 instance - amazon-web-services

I deploy my ASP.NET web site to ec2 instance via Elastic Beanstalk. When I test my site (upload file of 23 megabytes in size) Elastic Beanstalk terminate the instance. A problem in that on ec2 instance I must to use some externall dlls and licenses for their. But after terminating they are removed. How can I configure Elastic Beanstalk do not terminate instance?

First, if it is terminating the instance when you upload a large file it is because some error is occurring on the server causing it to fail status checks. You need to look at the server logs to determine what the issue is and work on that.
Second, if you are manually copying licensed files to Elastic Beanstalk instances and any auto-scaling event in Elastic Beanstalk is breaking your application then Elastic Beanstalk is not a good fit for your application. You should probably be using a plain EC2 server isntead of Elastic Beanstalk.

Related

Getting same type of Elastic Beanstalk EC2 logs without Elastic Beanstalk

I am currently using AWS Elastic Beanstalk to host a web application. I found that I can get logs for my running EC2 instances through the Elastic Beanstalk console. These logs contain detailed information such as web/app server logs etc.
If I am not working with Elastic Beanstalk and I create the resources needed to run my web app without using Elastic Beanstalk, is it possible to get the same type of logs in the picture above? Logs which show web/app server logs. I tried clicking on the EC2 instace -> instance settings -> get system logs, although this does not return the detailed logs which I receive from the Elastic Beanstalk console, as you can see below.
Is it possible to get this type of EC2 logs, if I am not using beanstalk?
Unfortunately you can't, at least not out of the box. There is a special log collector script that runs on EB environments to grab those logs, which I don't think is open source or available on Github (unlike the EKS or ECS log collectors).

How do I keep application deployed on EC2 Server for long?

I have an spring boot application which is deployed on EC2 server which runs fine.
But after a certain amount of time, that task is killed automatically. I have tried to search for a solution but couldn't find any or may be I didn't exactly know what to search for. And hence the question on SO.
Is there anything that I can implement which will keep on pinging the instance which will keep it alive?
If yes, how do I implement it? And do I have to consider any other drawback for doing this?
Option 1. Elastic Container Service
Dockerize your app. Create a ECS cluster and publish you service. You Docker container will still run on a EC2 instance, but ECS will automatically maintain the number of app instances "alive". If you container gets killed (because the main Java process got killed), ECS will automatically restart the container.
Option 2. Elastic Beanstalk
Publish your Java app with Elastic Beanstalk and it will automatically monitor the "health" of you web app, and replace "unhealthy" EC2 instances automatically. It only works for web apps, since Elastic Beanstalk does HTTP(S) checks calling a URL you specify.
Option 3. Use Elastic Load Balancer with Auto Scaling Group
ELB can do HTTP(s) checks on you app. If an instance doesn't respond, it will be automatically replaced. You will require to create an AMI or cloud-init script to bootstrap new instances.

AWS EC2 and Elastic Beanstalk

I am new to AWS and the question may seem very basic. However I need to see if I can find a solution to this.
I have created and launched an EC2 instance first and then created an Elastic Beanstalk instance with a sample application deployed on it. By default, the Elastic Beanstalk attaches "Default Environment" to this instance and I find no way to change this to my EC2 instance. How can I attach my EC2 instance (that I created earlier) to this Elastic Beanstalk instance? I am using Amazon Free Tier to learn.
Thanks a lot for your time and patience.
You cannot add an existing instance into an Elastic Beanstalk configuration.
Under the hood Elastic beanstalk uses Containers and a ton of configuration hooks, files, etc.
An instance is not the same and cannot even be guaranteed to be of matching types (perhaps the instance is CentOS and the Container runs on an ubuntu host).
It's simply not possible.

Amazon Elastic Beanstalk fault recovery

I have a running Amazon Elastic Beanstalk environment.
Sometimes it runs into problems and the load balancer kills my ec2 instance and starts a new one. I don't know how to create an "AMI" or template so the load balancer starts a new ec2 instance which is exactly like the one that I have configured.
Also, I attached some EBS blocks and I want to be able to create a new instance with a EBS block attached.
How can I do that?
I read the documentation but I cannot find what I need, and I think this is a common scenario.
Thanks
You should use .ebextensions to configure your Elastic Beanstalk instances. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html
These configurations and dependencies are handled on instance start-up.

AWS EC2: Why does ".NET Beanstalk HostManager v1.0.1.1" keep coming back

I keep killing the default instance and it keeps coming back. Why?
This answer is based on the assumption that you are facing a specific issue I've seen several users stumbling over, but your question is a bit short on detail, so I might misinterpret your problem in fact.
Background
The AWS Toolkit for Visual Studio allows you to deploy applications to AWS Elastic Beanstalk, which is a Platform as a Service (PaaS) offering allowing you to quickly deploy and manage applications in the AWS cloud:
You simply upload your application, and Elastic Beanstalk
automatically handles the deployment details of capacity provisioning,
load balancing, auto-scaling, and application health monitoring.
You deploy an application to Elastic Beanstalk into an Environment comprised of an Elastic Load Balancer and resp. Auto Scaling policies, which together ensure your application will keep running even if the EC2 instance is having trouble servicing the requests for whatever reason (see Architectural Overview for an explanation and illustration how these components work together).
That is, your Amazon EC2 instances are managed by default, so you don't need to administrate the infrastructure yourself, but the specific characteristic of this AWS PaaS variation is that you still can do that:
At the same time, with Elastic Beanstalk, you retain full control over
the AWS resources powering your application and can access the
underlying resources at any time.
Now that's exactly what you unintentionally did by terminating the EC2 instance via a mechanism outside of the Elastic Beanstalk service, which the load balancer detects and, driven by those auto scaling policies, triggers the creation of a replacement instance.
Solution
Long story short, you need to terminate the Elastic Beanstalk environment instead, as illustrated in section Step 6: Clean Up within the AWS Elastic Beanstalk Walkthrough (there is a dedicated section for the Elastic Beanstalk service within the AWS Management Console).
You can also do this via Visual Studio, as explained in step 11 at the bottom of How to Deploy the PetBoard Application Using AWS Elastic Beanstalk:
To delete the deployment, expand the Elastic Beanstalk node in AWS
Explorer, and then right-click the subnode for the deployment. Click
Delete. AWS Elastic Beanstalk will begin the deletion process, which
may take a few minutes. If you specified an notification email address
the deployment, AWS Elastic Beanstalk will send status notifications
for the delete process to this address.