Now you are ready to take a look at another commonly used option, especially for newcomers on AWS, which is AWS Elastic Beanstalk. Beanstalk is an application management platform that targets web applications; it is commonly referred to as a Platform-as-a-Service (PaaS) solution. It is a great option, especially for newcomers, because it hides a lot of the underlying complexity of setting up a complete environment for a web application and, as such, it doesn’t require you to have a deep knowledge of cloud computing. At the same time, it supports a broad variety of runtime environments, such as Java, .NET, Python, Node.js, PHP, Ruby, Go, and Docker. So, if your application is developed in a language for which Beanstalk does not directly offer a runtime environment, you can package it with all its dependencies in Docker containers, which Beanstalk can handle.
Now, even if Beanstalk makes your life easier by abstracting away much of the complexity of the underlying infrastructure, it still allows you as much control as you need over your infrastructure, should you prefer to manage parts of it yourself. Beanstalk relies on other AWS services, such as EC2, AWS Auto Scaling, Elastic Load Balancing (ELB), Amazon Relational Database Service (RDS), and Amazon S3, to provision an environment that supports your application.
To illustrate how it works, start with a simple Hello World sample application. You can grab the application from GitHub, for instance, using the following Command-Line Interface (CLI) in a shell terminal window:
$ git clone https://github.com/aws-samples/aws-elastic-beanstalk-express-js-sample.git
Note
Please note that these commands will work in a Bash shell terminal on macOS or Linux, so you will need to adapt them if you use a different shell or even a different OS.
Then change to the newly created directory where your sample application code now resides:
$ cd aws-elastic-beanstalk-express-js-sample/
The following steps make the assumption that you have already installed the Beanstalk CLI. If you haven’t, please refer to the Beanstalk CLI documentation at https://packt.link/EcLMT.
The immediate next step is to initialize the Beanstalk environment for this application. You can either provide the required parameters or use interactive mode to feed them to Beanstalk. For the latter, you can simply run the following command:
$ eb init
The Beanstalk CLI will then guide you by asking questions to define the environment where your application will run and will provide default values for when you’re not sure what to choose. You will be asked to specify things such as these:
Once the eb init command completes, your application is ready to be created. You can proceed to the next stage, which is the actual creation of the environment on Beanstalk and the deployment of your application to the newly created Beanstalk environment.