Elastic Beanstalk: Developer's AWS paradise
Tags: aws, elb, devops, webdev
Published: 2022-11-20 09:42:11

## Beanstalk in a nutshell

Starting with the cloud, it can be pretty intimidating because of all the fancy words you hear while learning. Auto-scaling and resource provisioning are just a couple of phrases that may be confusing for new developers. Besides that, most developers just want their code to run, without digging deep into hosting technology. Especially when deadlines are approaching.

Enters the room, Elastic Beanstalk. It is a managed service that helps developers run their web applications fast and without worrying about best practices in the AWS environment. It is used by both new and more experienced developers since it is easy to set up but also rich with features so you can tailor your system to your custom needs.

But first, what does managed service even means? It means AWS itself is managing everything. You don't need to worry about updates, security patches, and every other detail that is essential for running the application securely and consistently.

What is your job then? Just provide an overview of what your system needs and upload a code. It is that simple. You simply upload your code and Elastic Beanstalk automatically handles the deployment, from capacity provisioning, load balancing, and automatic scaling to web application health monitoring.

## How it works

Beanstalk works with the application/environment model. You create your application, and then you can have multiple environments for it. This basically means you can have completely different system architectures for different environments. For example, your server could run in only one instance for the development environment but have scaling functionalities implemented for production. And what do you need to do there? Just pick the options for scaling. Pick how many instances should be running minimally and maximally. Pick the thresholds for spinning new instances and terminating unused instances. Everything else is managed by Beanstalk itself.

You have the freedom to choose the deployment options for your applications. Some of them are All at once, Rolling, Blue/Green... This will not be covered in this blog post but it is mentioned to point out the vast range of features Beanstalk has.

## Supported Platforms

Beanstalk supports a wide variety of platforms. The list is as follows:

- GO
- JAVA SE
- JAVA Tomcat
- .NET with IIS
- NodeJS
- PHP
- Python
- Ruby
- Packer builder
- Single Container Docker
- Multi Container Docker
- Preconfigured Docker

New platforms are added constantly. There is also one nice feature that makes Elastic Beanstalk perfectly capable of every need you can think of. It is called Custom platform. You can completely configure the platform you need for your applications. This is very important for companies that have a lot of custom system configurations. Custom platform has a major drawback though. It is seen as a very advanced feature which means that it is not easy at all to create your personalized platform.

## Beanstalk CLI

We can install an additional CLI called the EB CLI which makes working with Beanstalk from the CLI easier. It’s helpful for your automated deployment pipelines!

After configuration of the environment, you can basically set up one command that will deploy your whole application.

## Creating your first Beanstalk web app

### Starting point

First login to your AWS account, and search for Elastic Beanstalk. 
When you land on EB service home page, click on create a new application.

You will then be redirected to page shown below:

![Create application form](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sfbr89jm63zv2irmuyxx.jpg)

This is the place where you give your application the name, pick a platform and upload your code. This is basically all you need to do for your application to be deployed. Of course, you can manually configure in more detail by clicking Configure more options button. This is what we will do to check more in depth configurations.

As you can see, you can use Sample application code. AWS has sample source codes for every platform, so you can get a hang of most common Beanstalk features without the need for any code from your side.

### Overview of most common environment configurations

After clicking on Configure more options button, you will land on Configure environment page:

![Application environment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/srl3a0djsw8pr0nw95i2.png)

This is where the magic happens. As you can see, configurations are categorized so it is easier to configure individual resources for your application.

We will go through the most important ones, but feel free to experiment with all. Just be aware that, even though Beanstalk is free, resources provisioned by it, that are out of free tier will be charged, so don't forget to check the pricing pages or erase all of the resources if you are just researching Beanstalk capabilities. 

Presets:

![Presets](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/541s4ca2l70gdwb89r4u.png)

Presets, also called deployment modes, tell Beanstalk the overall architecture you want for your environment. Single instance presets are great for development and testing. As the name suggests they use one instance (server) for running your web app. 

High availability presets are most commonly used in production. They are leveraging the load balancer features and they use auto-scaling.

Platform:

![Platform](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vw2np0is5y20muoomy6x.png)

This is the place where you can pick your platform and its version.

Software:

![Software](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h82ozdp3zidzgi38xrgz.png)

Software category is used for your software-related configs. You can set your environment variables (called environment properties here) in software configuration. Bye, bye env files.

Instances:

![Instances](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h5r3308mqoiigpqwh6oe.png)

Here you can configure your instances memory resources and public availability. In high availability applications, it is best practice to keep your instances private while the load balancer should be public, which will route all the traffic to your application.

Load balancer:

![Load Balancer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ncu0jd42q28pczwqy2ro.png)

Load balancer type, as well as listeners, protocols and ports, are configured here

Capacity:

![Capacity](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/abocfo2a0z5m9m4t6u9f.png)

In capacity section, you choose your EC2 instance type and system image. Basically, this is the same old school EC2 configuration

Security:

![Security](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3tmkfykeu0ad837l1ec.png)

And last but not least, security. This is where the role is created that performs all the deployment actions on your behalf. It is also the place where you will need to create and assign private keys for SSH access to your instance(s).

After you are ready click on create an app and let Beanstalk create every resource for your application. After a few minutes, you should land on the page below, and if everything is OK, your application should be fully deployed. 

![Environment health page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/op3iufz4dz7w3ho59uwg.png)

Use link below environment name to visit your Beanstalk application.

## Outro

This is just scratching the surface of one of the most powerful tools AWS is providing to developers. I hope I could show you how EB can save developers time every day while also being a platform where developers can learn about cloud best practices. Elastic Beanstalk is the service you should definitely have in your cloud tools arsenal.