Deploy Application to AWS Elastic Beanstalk

In this article, we will see how we can deploy new application to AWS Elastic Beanstalk. We will see what is Amazon Elastic Beanstalk in details.

Creating an Amazon Elastic Beanstalk involves several steps, and I’ll guide you through the process in a simple and detailed manner. Before that we will see in details what is actually a Amazon Elastic Beanstalk & Why we use it in our production.

What is AWS Elastic Beanstalk?

elastic bean

AWS Elastic Beanstalk is an AWS-managed service for web applications. Elastic Beanstalk is a pre-configured EC2 server that can directly take up your application code and environment configurations and use it to automatically provision and deploy the required resources within AWS to run the web application. Unlike EC2 which is Infrastructure as a service, AWS Elastic Beanstalk is a Platform As A Service (PAAS) as it allows users to directly use a pre-configured server for their application.

Of course, you can deploy applications without ever having to use elastic beanstalk but that would mean having to choose the appropriate service from the vast array of services offered by AWS, manually provisioning these AWS resources, and stitching them up together to form a complete web application. Let’s take an example to go deep into AWS Elastic Beanstalk.

Example:- AWS Elastic Beanstalk is like a magic box for your web applications on the internet. Imagine you have a cool website or app that you want people to see. Now, normally, you’d need to set up a bunch of things on the internet to make it work – like a server (which is like a computer that runs your app), Databases, VPC, Security Groups and other stuff. But AWS Elastic Beanstalk is like a helpful friend. You just give it your website’s code and tell it how you want things to run, and it takes care of all the complicated stuff for you. It’s like having a pre-made server that already knows what to do with your website.

Now, the cool thing is, with AWS Elastic Beanstalk, you don’t have to worry about figuring out which server to use or how to set it up. It’s like having a magic box that you just throw your website’s code into, and Your website is up and running on the internet.

This raises a concern that if AWS Elastic Beanstalk configures most of the resources itself and abstracts the underlying details. Can developers change the configuration if needed? The answer is Yes,  AWS Elastic Beanstalk is provided to make application deployment simpler but at no level will it restrict the developers from changing any configurations.

Features of AWS Elastic Beanstalk

  1. Ease of Use:
    • Elastic Beanstalk abstracts away the complexity of infrastructure management. Developers can focus on writing code without worrying about the underlying infrastructure details.
  2. Rapid Application Deployment:
    • Deployment is simplified with Elastic Beanstalk. Developers can easily deploy applications with just a few clicks or through command-line tools.
  3. Multi-Language Support:
    • Elastic Beanstalk supports multiple programming languages, including Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker. This makes it versatile and suitable for a wide range of applications.
  4. Managed Environment:
    • Elastic Beanstalk automatically handles the deployment of application components like web servers, databases, and load balancers. It ensures that the underlying environment is up to date, patched, and secure.
  5. Automatic Scaling:
    • Elastic Beanstalk can automatically scale your application based on traffic and demand. It supports both manual and automatic scaling options, making it easy to handle varying workloads.

How AWS Elastic Beanstalk Works ?

You can construct an application using AWS Elastic Beanstalk, upload an application version in the form of an application code bundle (for instance, a Python.war file), and then provide some information about the program. The AWS resources required to run your code are automatically created and configured by AWS Elastic BeanstalkYou can manage your environment and roll out new application versions once your environment has launched. The workflow of Elastic Beanstalk is shown in the diagram below.

Workflow1

AWS Elastic Beanstalk Pricing

AWS Elastic Beanstalk itself is a free service, and there are no separate charges for using it. The pricing for AWS Elastic Beanstalk is based on the underlying AWS resources used to run your application. As a Platform as a Service (PaaS) offering, there is no additional charge for using Elastic Beanstalk itself. Instead, you pay for the AWS resources, such as Amazon EC2 instances, Amazon RDS database instances, and Amazon S3 storage, that your application consumes. The pricing factors include:

  • Amazon EC2 Instances: The cost of EC2 instances is determined by the instance type, size, and duration of usage.
  • Amazon RDS Instances: If your application uses an Amazon RDS database, you’ll incur charges based on the RDS instance type and storage.
  • Amazon S3 Storage: The storage cost is calculated based on the amount of data stored in Amazon S3 buckets.
  • Data Transfer: If your application serves content to end-users, data transfer charges may apply based on the amount of outbound data transferred.
  • Load Balancer: If your application uses an Elastic Load Balancer, you’ll be billed for its usage.
  • Other AWS Services: Additional AWS services integrated with Elastic Beanstalk may have associated costs, such as Amazon CloudWatch for monitoring.

AWS Elastic Beanstalk Supported Platforms

AWS Elastic Beanstalk provides a number of platforms on which we may develop our apps, deploy our code, and it manages the entire supporting architecture and computational resources for code execution. Following are the Platforms for programming languages provided by AWS Elastic Beanstalk.

Platforms for Programming Languages Provided By AWS Elastic Beanstalk are:

  • GO
  • Java
  • Node.js
  • PHP
  • Python
  • Ruby
  • Docker

Platforms for Application Servers Provided by AWS Elastic Beanstalk are:

  • Tomcat
  • Nginx

AWS Elastic Beanstalk Components

  • Application: Elastic Beanstalk directly takes in our project code. So Elastic Beanstalk application is named the same as your project home directory.
  • Application Environments: Users may want their application to run on different environments like DEV, UAT, and PROD. You can create and configure different environments to run applications on different stages.
  • Environment Health:  One of the most lucrative features of running applications on AWS or most of the other cloud platforms is automated health checks. AWS runs automatic health checks on all EC2 deployments (Elastic Beanstalk is a managed EC2 service) which can be monitored from the AWS console. For example, in the case of web applications AWS will regularly, as scheduled by the developers, ping the application to check if the response is status code 200 and if the application is running as expected. Health check responses:
    • Red: The application failed all health tests.
    • Yellow: The application failed some of the health tests.
    • Grey: The application is updating.
    • Green: The application passed the health check successfully.
  • Isolated: All environments within a single application are isolated from each other (independent of each others’ running states). Needless to say, two different applications are also isolated.
  • Scalability: Using Auto-Scaling within Elastic Beanstalk makes the application dynamically scalable.
  • Elastic Load Balancing: All the web requests to the application are not directly relayed to application instances. They first hit the Elastic Load Balancer (ELB), which, as the name suggests, balances the load across all the application instances.
  • Language support: Elastic Beanstalk supports the applications developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS.
  • Pricing: There is no extra charge for using Elastic Beanstalk. Users are only required to pay for the services and resources provisioned by Elastic Beanstalk Service.
  • Automatic Provisioning: Elastic Beanstalk takes away the burden of choosing the right services and configuring their security groups to work together. 

Prerequisites

Before proceeding, make sure you have the following prerequisites in place:

  • You’ll need an Amazon Web Services (AWS) account. If you don’t have one, you can sign up for a free AWS account.
  • Basic knowledge of AWS services and concepts.

How to Deploy an Application Using AWS Elastic Beanstalk Step By Step

Step 1: Visit the AWS Console and type “Elastic Beanstalk into the search bar.

search 1

Step 2: After selecting “Elastic Beanstalk” from the search menu, you will be taken to the Elastic Beanstalkpage where you can click “Create application” to launch a sample application using Elastic Beanstalk.

aws.text2

Step 3: In this step, we are going to configure the necessary Application information like Name, and key-value pairs and select the platform in which the language the application is developed has to be deployed, the Platform BranchPlatform Version, and Application Code etc.

In environment tier section, Select web server environment, then in application information section add application name as per your requirement mine is “Pythonfile”. Application Tag is optional if you want to add then add otherwise leave default this section.

In environment information section it automatically configure your application name and other things which is you mention above. In platform section, select platform type as “managed platform”. Add platform as “Python” (this is your code platform) and platform branch & platform version will automatically define.

In application code section, select upload your code option and then after that add your application version label mine is “2” version label which you are going to provide must be unique. After this select “local file” option and next select “choose file” option then upload your zip or war file from your local machine. In presets section, select “single instance (free tier eligible)” option. After all this click on “Next”.

Example: In this example, we are going to deploy the sample Python application which is provided by AWS itself select all the options as shown in screenshot.

env
env 1
platform
file
next

Step 4: In Configure service access page, go to service access section, choose “use an existing service role” option. Before that you have pre-created role for “Elastic Beanstalk” and “EC2” and Also have a policies of all “Elastic Beanstalk” and all “EC2” in that role. Here which i have already created and mine role name is “aws-elasticbeanstalk-ec2-role-only”. We can see role and policies from “IAM Dashboard”. Here you can see my pre-created role and policies. After this click on “Next”.

Note: We need to configure service access and create a role for Elastic Beanstalk so that it can assume this role when calling services on our behalf. This allows Elastic Beanstalk to automatically deploy new versions of our application.

service

Step 5: In the networking, database, and tags section, choose Default VPC, Enable Public IP address, and select availability zone as “us-east-1a” and leave other settings as default. Then click on “Next”.

db
instance

Step 6: Create a security group by going to EC2 Dashboard > Security Groups > Create security group. After that Create a security group that allows “HTTP” ,”HTTPS”, and “SSH” traffic from “ANYWHERE”.

aws.text3

Here in this example I’ve already created a security group and mine security group name is “my web”. In capacity section, you can select option according to your need like “Auto scaling group”, “Architecture”, “Instance types” etc. Here in this example we are using everything as default. Click on “Next”.

aws.text4
t3

Step 7: Under Configure updates, monitoring, and logging, choose “Basic” Health Reporting and De-select “managed platform updates”. Let rest everything leave default and click on “Next“.

basic
manage

Step 8: Review everything and click on submit. Here you will see that your application is being created.
Note: Elastic Beanstalk takes about 5-10 minutes to create the environment.

Step 9: Once your application is up and running, you can check the “Health Status” and you can also check the status from the bottom of the page. In “Event” section where you can see the all details of your environment. Once it will success then you can see the message like “successfully launched environment: Pythonfile-env” it means your application is ready to serve on internet.

image 4
logs

Step 10: Now, click the URL or Domain it will redirect to the sample website which is served from your server.

aws.text

Conclusion:

In this article, we’ve demonstrated How To Deploy New Application To AWS Elastic Beanstalk. In simple words, AWS Elastic Beanstalk is an automatic application deployment service. It is the easiest possible way to deploy your applications on AWS even with possibly no prior experience on the platform.

Reference:-

Any queries please contact us @Devopshint.

Related Articles:

How to Create OpenSearch Service Domain in AWS

About Sohail Behlim

Hey, I am Sohail Behlim, I am an aspiring DevOps and Cloud enthusiast who is eager to embark on a journey into the world of DevOps and Cloud. With a strong passion for technology and a keen interest in DevOps and Cloud based solutions, I am driven to learn and contribute to the ever-evolving field of DevOps and Cloud.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link