JavaRush /Java Blog /Random EN /Deploy a Java application to the Amazon Web Services (AWS...
Евгений
Level 41

Deploy a Java application to the Amazon Web Services (AWS) cloud platform

Published in the Random EN group
Hi all! Every developer sooner or later has to deploy their applications to the cloud. In my case, after developing the Telegram bot @rabotaUkraineBot, it became simply necessary to find a decent hosting for it. The very idea of ​​developing a bot and the tools used for implementation are described in a separate article . The candidates for choosing a cloud platform were the services of four well-known giants - Amazon Web Services (AWS), Google, Azure and Heroku. When choosing hosting for myself, I set the following priorities: minimum price, ease of deployment, availability of additional services, flexibility. I won’t immerse you in analytics and comparisons; I’ll tell you right away the winner - AWS. Deploy a Java application to the Amazon Web Services (AWS) cloud platform - 1Why AWS, you ask? Because:
  • a year of free use of AWS Free Tier , free resources within this offer are more than enough for my task;
  • in AWS everything is Elastic, i.e. everything is flexible and elastic. Thanks to this, DevOps skills are absolutely not required when deploying your application;
  • AWS has been investing heavily in development over the past two years, with new services appearing every month.
Now let’s move on to preparing the application and the deployment itself to the AWS cloud. For ease of use, the Elastic Beanstalk service was chosen to deploy the application. With it, you download your application through your browser and that’s it! Yes, yes, AWS will set up the infrastructure itself and allocate the required pool of resources. Since my bot is written in SpringBoot, all that is needed is to build a war using spring-boot-maven-plugin and check that the application works correctly on a locally deployed Tomcat . A very important note, before building you need to set the port number 5000 in application.properties:
server.port=5000
If you do not do this, you will have to configure the port settings in the AWS console, which may incur additional charges from AWS because this goes beyond providing the AWS Free Tier service. The deployment process itself is absolutely not complicated and is done according to the official Getting Started Using Elastic Beanstalk guide . Features you should pay attention to:
  • When building the application, do not forget to configure the port as indicated above;
  • when registering with AWS, you will need a payment card with at least $1 in your account (when validating the card, Amazon blocks $1);
  • carefully study the limitations of the AWS Free Tier service so as not to lose money;
  • If after deployment the application does not work as expected, you will find Tomcat logs in the Logs menu in the Environment of your application.
What to do a year after using the free period, you ask? There are several options to resolve the issue:
  1. start paying money according to the resources used;
  2. switch to the Amazon Lightsail service (it’s cheaper there);
  3. rewrite the application using AWS Lambda and get free hosting;
  4. open a new account with AWS Free Tier services and deploy your application there, i.e. delay the resolution of the issue for another year.
Currently, AWS only checks the uniqueness of the e-mail when registering a new account. To summarize: you can easily deploy your application to the AWS cloud - very quickly and absolutely free for the first year. Thanks to AWS services, we can concentrate on development, AWS will do the rest for us, because everything is Elastic there.
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION