Tutorial : Deploy your Java app with AWS Elastic Beanstalk - Tutorial

To deploy your Spring Boot app in the web it really takes only 5 minutes thanks to AWS Elastic Beanstalk.

For the deploy we can choose multiple sources: code, docker image or deployable jar/war. In this example we shows the deploy through a war.


  1. a Spring bootable web application (Web Server embedded). For this tutorial I use the demo app : https://github.com/marco76/SpringAngular2TypeScript
  2. configure the server.port of your Spring application to 5000. BeanStalk install ngix that redirect the public port 80 of the server to the internal port 5000. You can change application.properties or set a system variable in AWS.
  3. an account with AWS (the deployment of application in AWS is not free).

Step by step procedure

  1. In the AWS services select ‘Elastic Bean’.
<img class="alignnone size-full wp-image-971" src="/assets/img/uploads/2017/03/1.png?resize=355%2C200" data-recalc-dims="1" /> 
  1. Click on ‘Create new application’.
<img class="alignnone wp-image-957" src="/assets/img/uploads/2017/03/2.png?resize=209%2C67" data-recalc-dims="1" /> 
  1. Choose a name and write a description to your application.
<img class="alignnone wp-image-958" src="/assets/img/uploads/2017/03/3.png?resize=310%2C191" data-recalc-dims="1" /> 
  1. This will create your environment, you need to generate a new application. Click on ‘create one now’.
<img class="alignnone wp-image-966" src="/assets/img/uploads/2017/03/4.png?resize=428%2C77" data-recalc-dims="1" /> 
  1. Choose ‘Web server environment’.
<img class="alignnone wp-image-969" src="/assets/img/uploads/2017/03/5.png?resize=330%2C216" data-recalc-dims="1" /> 
  1. Select Java in the ‘Preconfigured platform’.
<img class="alignnone wp-image-975" src="/assets/img/uploads/2017/03/6.png?resize=355%2C213" data-recalc-dims="1" /> 
  1. Don’t change the option in ‘Application code’. AWS will install a default application.
<img class="alignnone wp-image-961" src="/assets/img/uploads/2017/03/7.png?resize=345%2C170" data-recalc-dims="1" /> 
  1. At this point you can ‘Create environment’ to create your server instance.
<img class="alignnone wp-image-967" src="/assets/img/uploads/2017/03/10.png?resize=355%2C46" data-recalc-dims="1" /> 
  1. (Optional) You can choose to customize the options of the server configuration (an EC2 instance is created). In our example we don’t change anything, the configuration suggested by Amazon is enough).
<img class="alignnone wp-image-962" src="/assets/img/uploads/2017/03/8.png?resize=333%2C268" data-recalc-dims="1" /> 
  1. After the confirmation the server instance is created and the demo application deployed.
<img class="alignnone wp-image-964" src="/assets/img/uploads/2017/03/9.png?resize=372%2C71" data-recalc-dims="1" /><img class="alignnone wp-image-968" src="/assets/img/uploads/2017/03/11.png?resize=382%2C200" data-recalc-dims="1" /><img class="alignnone size-full wp-image-970" src="/assets/img/uploads/2017/03/12.png?resize=400%2C132" data-recalc-dims="1" /> 
  1. Near the name of your application there is the clickable URL that allows you to open the app.
<img class="alignnone size-full wp-image-965" src="/assets/img/uploads/2017/03/13.png?resize=955%2C43" data-recalc-dims="1" /> 
  1. Here the sample application installed by AWS.
<img class="alignnone size-full wp-image-972" src="/assets/img/uploads/2017/03/14.png?resize=400%2C250" data-recalc-dims="1" /> 
  1. To deploy your application you have to click on ‘Upload and Deploy’ in your dashboard.
<img class="alignnone size-full wp-image-963" src="/assets/img/uploads/2017/03/15.png?resize=220%2C121" data-recalc-dims="1" /> 
  1. Upload the war that you want to deploy and give a version name to this deploy, e.g. : ‘My First app version 1.0’. All the deployments are archived in S3 and you can easily redeploy a previous version.
<img class="alignnone size-full wp-image-959" src="/assets/img/uploads/2017/03/19.png?resize=350%2C188" data-recalc-dims="1" /> 
  1. When the deployment is terminated you can click on the URL link and see your application deployed!
<img class="alignnone size-full wp-image-960" src="/assets/img/uploads/2017/03/17.png?resize=500%2C297" data-recalc-dims="1" /> 

Congratulations! 🙂

How to delete your environment

At this point you have many interesting options, p.e. you can copy your environment, save the configuration or, my choice, to delete the servers.

This server has been created only for this tutorial, now I can delete it choosing ‘Terminate environment’, after confirmation AWS will destroy the instance created and all the related objects.

WebApp built by Marco using SpringBoot, Java 17, Mustache, Markdown and in Azure