Deploy Applications to AWS Elastic Beanstalk
In this guide, We will learn to deploy an app into Elastic Beanstalk with High availability.
What is Elastic Beanstalk?
Elastic Beanstalk provides a way to set up and deploy applications in the AWS cloud in an easy manner.
We have to focus on the application code and upload it to the Beanstalk environment which automatically scales the infra depending on the incoming traffic.
There are two ways apps can be deployed into the Elastic Beanstalk environment.
● Using AWS Console
● Using EB CLI (a command-line utility)
Supported Programming Languages
The following platforms are supported by Elastic beanstalk.
● PHP
● Docker
● Python
● Java
● Node.js
● Ruby
● GlassFish
● Go
● Tomcat
● .NET on Windows and Linux
Choose the platform using which the application is built.
How it works
The below diagram represents the workflow of deploying applications into Elastic beanstalk
● Application setup with the preferred platform along with the source bundle will be created
● The Environment such as Instance, Load Balancing, Auto Scaling will be created to deploy the applications
● Versioning will be maintained for redeployment and rollback
Deploying Applications
Let’s go ahead and deploy a sample Node.js application into Elastic Beanstalk,
Sign in to AWS Console,
Under Computer, Select Elastic Beanstalk
Click Create Application
Creating a Web Application
In this step, We will set up an application by choosing the preferred application platform.
Enter the application name
For Platform, Select Node.js which will automatically select the Platform branch and the Platform version
You May Also Like: AWS vs Azure vs Google Cloud
For the Application code, Choose Sample application
Configuring Environment
We must configure the environment where the application code will be deployed.
Environmental setups such as Instance, Security Groups, Load Balancing, VPC Network, and Database will be configured.
Click Configure more options
Now it’s time to configure the environment for the Zenesys web application
For this guide, We will choose to deploy the applications in the High Availability setup.
For Instances, Click Edit,
We should configure the EBS storage size and the storage type.
Let the Root volume type be a General purpose SSD and the volume size be 20 GB.
Under EC2 security groups, Choose the preferred security group name, where we can configure the ports later if required, and click Save
Under Capacity, Click Edit
The Environment Type will be Load balanced.
Here we have to specify the minimum and maximum number of instances required during Scale-in and Scale-out.
Let the min be 2 and the Max be 4
Choose the preferred Instance type.
And the AMI ID from which you want to launch the EC2 instances.
And the Availability Zones are Any.
Next, we have to configure, Based on what parameter, the autoscaling on instances should work.
Under Scaling triggers, Let the
Metric be CPU Utilization
Statistics be Average and Unite be Percent.
And set the Upper and lower threshold.
And click Save.
Under Load balancer, Click Edit
Choose the type of Load balancer required and click Save.
To SSH into the EC2 instances launched as part of the Elastic Beanstalk environment, We need to configure the SSH key pair.
Under Security, click Edit and choose the EC2 key pair and click Save.
Under VPC, click Edit
We have to choose the VPC and the subnets where the environment setup for the application should be created.
Here we have to configure subnets for the Load Balancer and the EC2 instances.
Select the VPC and Under the Load balancer settings,
The Visibility of the load balancer is Public.
And choose the subnets from the different availability zones.
For Instance settings, As the traffic to the EC2 instances is routed using the public Load balancer.
We don’t have to enable the Public IP address for the EC2 instances.
Choose the subnets from Different Az for the EC2 instances and click Save.
Now it’s time to click Create an app to deploy the application into the Elastic Beanstalk environment.
The Environment has started to create.
It will take a few minutes for the Environment and the application to be successfully deployed.
The Deployment is completed and the health of the application is OK.
Click the link, which will display the following page, which shows that the sample Node.js application is deployed into the elastic beanstalk environment.
Conclusion
We have successfully deployed a Node.js application into the Elastic Beanstalk environment with High availability and an Autoscaling setup.
Also Read: How to Set up a Static Website Using S3 Bucket & CloudFront Distribution