Elastic Beanstalk is one of the “computer” services in the Amazon Web Services (AWS) cloud. It allows us to easily manage and deploy applications. We don’t have to understand or learn the services required to run our application. With Elastic Beanstalk, we only need to upload our application and Elastic Beanstalk takes care of the rest. Elastic Beanstalk supports applications developed in Java, .NET, Go, PHP, Python, Node.js and Ruby.

We can interact with Elastic Beanstalk using the AWS Management Console, Command Line Interface.

To use Elastic Beanstalk, all we need to do is build our application, upload its version in the form of a source bundle (e.g., the Java application requires a .war file), and then provide some information about the application. Elastic Beanstalk then automatically launches an environment and creates and configures the AWS resources needed for our code. Elastic Beanstalk even manages the environment itself. We don’t have to worry about high availability, scaling, etc.

There are no additional costs for Elastic Beanstalk. We only pay for the AWS resources that our application will use and need. For pricing details, please refer to the official AWS documentation here.

Before proceeding further, let’s understand a few basic concept of Elastic Beanstalk.

  1. Application:

    It is a logical collection of Elastic Beanstalk components, including environments, versions, and environment configurations. It is similar to a folder.
  2. Application Version:

    An application version is a deployable code, such as a Java WAR file. An application version is part of an application. 
  3. Environment:

    It is a collection of AWS resources running our application version, e.g. EC2 Instances, LoadBalancers, Security Groups, etc 
  4. Platform:

    It is a combination of an OS, programming language runtime, application server, and Elastic Beanstalk components. 

In this article, we will see how to create an Elastic Beanstalk Application with a Sample Code example.

Pre-requisites

  1. AWS Account (Create if you don’t have one). 

What we will do?

  1. Login to AWS.
  2. Configure and Create Elastic Beanstalk Application
  3. Terminate the Application

Login to AWS

  1. Click here to go to AWS Login Page.

When we hit the above link, we will see a web page as follows where we are required to log in using our login details.

<img alt="Login to AWS" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.40_.29_PM_.png5e9d9b4a5c583.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="437" src="data:image/svg xml,” width=”750″>

Once we login into AWS successfully, we will see the main console with all the services listed as follows.

<img alt="AWS Management console" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.40_.45_PM_.png5e9d9b4a95b03.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="417" src="data:image/svg xml,” width=”750″>

Configure and Create an Elastic Beanstalk Application

To create an Elastic Beanstalk application, Click on “Service” on the top left screen and search for “Elastic Beanstalk” in the search box and click on the result.

<img alt="Create an Elastic Beanstalk Application" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.27_.56_PM_.png5e9d9b4ac6438.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="418" src="data:image/svg xml,” width=”750″>

On this Welcome screen, click on “Get Started” to create our first application.

<img alt="Welcome to Elastic Beanstalk" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.28_.08_PM_.png5e9d9b4af01ae.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="417" src="data:image/svg xml,” width=”750″>

Here, we can give a name to the application, specify the platform of our choice. Here I have specified the Java platform as we are going to proceed with the sample application.

Before we proceed and click on “Create application”, click on “Configure more options” to see the available options.

<img alt="Create web app" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.28_.51_PM_.png5e9d9b4b27d77.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="417" src="data:image/svg xml,” width=”750″>

We will see the following screen, where we can see we have a lot of configurations available. Here, I am proceeding with the “Single Instance” as it is eligible for Free Tier, but for production purposes, we should not go with this type.

<img alt="Configure application" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.29_.19_PM_.png5e9d9b4b544a8.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="417" src="data:image/svg xml,” width=”750″>

Under “Software”, we can provide environment variables, enable log streaming, enable rotate logs, etc.

<img alt="Modify software" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.29_.48_PM_.png5e9d9b4b81198.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="417" src="data:image/svg xml,” width=”750″>

Under “Instance” we can choose the type of root volume type for the EC2 instance we want. The default is “Container” which does not require to specify the size. We can even use the existing security groups or Elastic Beanstalk will create the one required.

<img alt="Modify instanaces" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.30_.15_PM_.png5e9d9b4bad935.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="417" src="data:image/svg xml,” width=”750″>

Under “Capacity” we can see Min and Max instances is 1 as we have chosen a free tier eligible instance type in the previous step. 

In the same way, you can explore different options available and click on “Create Application” on the main page to create our first Elastic Beanstalk Application.Advertisements

<img alt="Modify Capacity" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.30_.43_PM_.png5e9d9b4bdcbe0.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="417" src="data:image/svg xml,” width=”750″>

Now, the required resources like EC2 instance, security group, scaling policies, load balancer, etc are being created. This will take some time, wait till then.

<img alt="Creating the application" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.33_.48_PM_.png5e9d9b4c12ad5.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="416" src="data:image/svg xml,” width=”750″>

After some time, in the logs, we can see that the application has successfully been deployed and now available to access. To access the application Hit on the URL available for the application.

<img alt="Access application by its URL" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.36_.13_PM_.png5e9d9b4c46cf8.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="419" src="data:image/svg xml,” width=”750″>

Once we hit the application, we can see that the sample application is now accessible from the browser.

<img alt="Sample application" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.36_.45_PM_.png5e9d9b4c70390.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="435" src="data:image/svg xml,” width=”750″>

Delete the Application

To delete the application if it is no more needed, click on “Actions” -> “Terminate Environment”.

<img alt="Remove Application from AWS" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.37_.12_PM_.png5e9d9b4c87199.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="417" src="data:image/svg xml,” width=”750″>

Provide the name of the application in the text box and click on “Terminate”.Advertisements

<img alt="Confirm Environment termination" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/04/echo/Screenshot_2019-12-22_at_3.37_.45_PM_.png5e9d9b4cb3ac0.jpg" ezimgfmt="rs rscb1 src ng ngcb1" height="416" src="data:image/svg xml,” width=”750″>

Conclusion:

In this article,  we saw the steps to create a very first Elastic Beanstalk Application with the sample code. We also saw how easily the application can be terminated.