JavaRush /Java Blog /Random EN /Deploy Java Application to Amazon Web Services (AWS) Clou...
Евгений
Level 41

Deploy Java Application to 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 the development of 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 cloud platform candidates were the services of four well-known giants - Amazon Web Services (AWS), Google, Azure and Heroku. When choosing a hosting for myself, I set the following priorities: minimum price, ease of deployment, availability of additional services, flexibility. I will not immerse you in analytics and comparisons, I will immediately announce the winner - AWS. Deploying 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 under this offer are more than enough for my task;
  • in AWS everything is Elastic, i.e. Everything is flexible and flexible. Thanks to this, DevOps skills are absolutely not needed when deploying your application;
  • AWS has been investing heavily in development over the past two years, with new services appearing every month.
And now let's move on to preparing the application and actually deploying it to the AWS clouds. For ease of use, the Elastic Beanstalk service was chosen to deploy the application. With it, you download your application through the browser and that's it! Yes, AWS itself will set up the infrastructure and allocate the required pool of resources. Since my bot is written in SpringBoot, all I need to do is build the war using the spring-boot-maven-plugin and test the application correctly on a locally deployed Tomcat . A very important note, before building, you need to put the port number 5000 in application.properties:
server.port=5000
If this is not done, then you will have to configure the port settings in the AWS console, which may incur additional fees from AWS. 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 to 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 (Amazon blocks $1 when validating a card);
  • carefully study the limitations of the free AWS Free Tier service in order not to get into the money;
  • If the application does not work as expected after deployment, you can find the Tomcat logs in the Logs menu in your application's Environment.
And what to do a year after using the free period, you ask? There are several options for resolving 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. postpone the decision of the issue for another year.
Now AWS checks only the uniqueness of the e-mail when registering a new account. To sum it up, you can easily deploy your application to AWS clouds - 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