AWS Elastic Beanstalk allows us to quickly deploy, monitor, scale and manage our application in AWS Cloud. This is without worrying about scaling, capacity management and health monitoring complexities that comes into deploying applications. It runs on highly reliable and scalable AWS Services.
Although this simplifies deployment of our application and reduces the management part of it, it doesn’t limit us to still have full control of the underlying infrastructure as compared to Container technologies. AWS Elastic Beanstalk supports different software and hardware stacks. It also supports applications written in Java, Python, PHP, Node.JS, etc.
For this example we will build a simple java web application and will deploy it in AWS Elastic BeanStalk. You can copy the source files from this repository. As a prerequisite you need JDK and ANT installed on your development environment.
Build the project by issuing the following
# ant war
[mkdir] Created dir: /home/project/build
[mkdir] Created dir: /home/project/build/WEB-INF
[mkdir] Created dir: /home/project/build/WEB-INF/classes
[mkdir] Created dir: /home/project/build/WEB-INF/lib
[copy] Copying 2 files to /home/project/build
[war] Building war: /home/project/dist/test.war
Total time: 0 seconds
Now that we have a sample war file let’s login to AWS Console.
Under Compute services, click Elastic Beanstalk.
We could deploy our application easily by selecting Tomcat from the “Select a platform” dropdown-list and hitting Launch Now. Our application will be deployed “auto-magically” but to get more control on the deployment process, click Create New Application located on the top right of the page.
In the Application Information page, provide a name for this deployment and click Next.
We need to choose an Environment Tier. As stated, a Web Server Environment typically supports standard web applications. Worker environment are more suited for applications that involves Queues and background processing. Since our dummy application is a java web application, select a Web Server Tier environment.
AWS ElasticBeanstalk support different web platforms. Select Tomcat from the Predefined configuration list. Under the environment type, we can configure this deployment to use a Single Instance or deployed under an Auto Scaling, Load Balancing platform.
In the next page, select our sample java web application project that we built. In future post, we’ll look into detail the deployment policy settings we could configure when we deploy an application in Elastic Beanstalk. Click Next.
In the Environment Information page, we can define in which logical environment this deployment is for. We could do a deployment mean for testing or prod. We could also aptly define the URL for which environment this deployment is for.
Under Additional Resources, we could select if we need an RDS DB in this deployment or if we need it to be under a specific / new VPC. Since we wont be using an RDS DB, we could just click Next.
Under Configuration details, this is the part where we could really control how our application is deployed. We can define and choose the type of instance. We also have the option to configure access to our instance by associating or creating an SSH Key pair that would allow us to remotely login to our EC2 instance.
As with any AWS services, we can define tags for this deployment.
Under Permissions, select the role you want to associate our instance. If the application needs to access different AWS Service, it is best to provide the instance or our application a Role rather than using shared login information/Access keys which open up security concerns.
Review your deployment configuration and hit Launch.
Take note of the Environment URL since we will be using that url to access our application.
AWS Elastic Beanstalk service will process and deploy our application. Everything is being logged and you can see what’s happening (creating instance, ELB etc) during the deployment process.
Once successfully deployed
you can browse our URL and check out our application.