DEV Community

Marble IT
Marble IT

Posted on

Elastic Beanstalk: Developer's AWS paradise

Beanstalk in a nutshell

Starting with the cloud 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 mean? It means AWS itself is managing everything. You don't need to worry about updates, security patches, and every other detail essential for running the application securely and consistently.

What is your job, then? Provide an overview of what your system needs and upload 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, and Blue/Green. These will not be covered in this blog post, but they are 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 a 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. The 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 configuring the environment, you can set up one command to deploy your whole application.

Creating your first Beanstalk web app

Starting point

First, log into your AWS account and search for Elastic Beanstalk.When you land on the EB service home page, click on Create a new application.

You will then be redirected to the page shown below:

Image description

This is where you give your application a 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 it in more detail by clicking the Configure more options button. This is what we will do to check more in-depth configurations.

As you can see, you can use the Sample application code. AWS has sample source codes for every platform, so you can learn the most common Beanstalk features without writing any code yourself.

Overview of most common environment configurations

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

Image description

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

We will go through the most important ones, but feel free to experiment with them all. Just be aware that, even though Beanstalk is free, resources provisioned by it, that are out of the 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:

Image description

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) to run your web app.

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

Platform:

Image description

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

Software:

Image description

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

Instances:

Image description

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 is public, which will route all the traffic to your application.

Load balancer:

Image description

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

Capacity:

Image description

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

Security:

Image description

Last but not least, security. This is where the role that performs all the deployment actions on your behalf is created. It is also 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.

Image description

Use the link below the environment name to visit your Beanstalk application.

Conclusion

This is just scratching the surface of one of the most powerful tools AWS is providing to developers. I hope I can 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.

Aleksandar Polić

Top comments (0)