How to Easily Deploy a Spring Boot Application to AWS EC2

Поділитися
Вставка
  • Опубліковано 3 лип 2024
  • The easiest way to deploy a Spring Boot application to the cloud is using AWS EC2. In this video I will show how to deploy a simple web application to EC2 in such a way it can be used from a CI/CD platform to upload a new version each time it's available.
    This video belongs to a playlist where I show multiple ways to deploy application to AWS: • How to Easily Deploy a...
    Content:
    * What is the cloud. What are the main cloud providers
    * What are the main services of AWS
    * How does AWS EC2 work
    * Which services are necessary to create an AWS EC2 instance. What is a Security Group. What is a VPC. What is S3.
    * How to connect to an AWS EC2 instance in SSH
    * How to create an AMI from a running AWS EC2 instance
    * How to perform automatic actions on a AWS EC2 instance at the startup
    My NEW eBook: sergiolema.dev/git-book/
    Blog: bit.ly/47ornJL
    LinkedIn: bit.ly/41Nn61q
    Facebook: bit.ly/47rc9nh
    My Desktop:
    • Laptop: Macbook Pro 16' 2019
    • Gaming Chair: amzn.to/47Vu6ed
    • Mouse: amzn.to/3HoBwM1
    • Desk: amzn.to/48Tc5Oi
    • Screen: amzn.to/48VZkCL
    Icons:
    * credit cart by Larea from Noun Project
    * comment by Gautam Arora from Noun Project
    * Server by Alzam from Noun Project
  • Наука та технологія

КОМЕНТАРІ • 125

  • @shashankbhat6184
    @shashankbhat6184 Рік тому +7

    Explanation is very clean. This video helped me a lot. Thanks🙏

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому

      Thank to you for watching! Don't forget to share my channel with your network

    • @shashankbhat6184
      @shashankbhat6184 Рік тому

      @@TheDevWorldbySergioLema Yeah, I'm sure my network will enjoy it 👍

  • @santiagoibarbia3958
    @santiagoibarbia3958 5 місяців тому

    Amazing video. All explained in just some minutes. Congrats!

  • @anthonycarella1779
    @anthonycarella1779 3 місяці тому

    The fact that half-way through this video, I was able to get a simple Spring Boot application on an EC2 instance makes it golden. Thank you so much!

  • @Apopjak
    @Apopjak Рік тому

    duuuude, U have no idea how much u helped me with this video, u re the best!

  • @user-sl6ch8hv8f
    @user-sl6ch8hv8f 7 місяців тому

    Explanation very clean and excellent, thank you

  • @pulato000
    @pulato000 Рік тому

    Cool, looking forward to another one

  • @lukamarkac6706
    @lukamarkac6706 9 місяців тому

    Beautiful video, props bro!

  • @mihailegorin2349
    @mihailegorin2349 Рік тому

    Thank you! Your video was very helpful for me

  • @user-kh9xs5lq9p
    @user-kh9xs5lq9p 7 місяців тому

    this tutorial is very helpful. thank you!

  • @ernestcronin8999
    @ernestcronin8999 4 місяці тому

    Excellent video. Thank you so much.

  • @bodyakov4483
    @bodyakov4483 Рік тому

    Great video, thank you!

  • @maYoutubeTube
    @maYoutubeTube 8 місяців тому

    Great video. Thank you

  • @MikeBrownphx
    @MikeBrownphx Місяць тому

    Great video.

  • @programmierenabisz4664
    @programmierenabisz4664 10 днів тому

    Thank you so much! This made so many things clear to me. I worked with several old ways to manage my projects. From hosting my own servers (about 20 years ago) to some docker managed instances and so on. AWS was a misterium for me. So many things you can do there but you brought it to the point for me. EC2 is only a virtual machine :) And the networking is also only networking VPC (virtual private cnetwork ;))

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  10 днів тому +1

      I'm so glad you understand it better now!

    • @programmierenabisz4664
      @programmierenabisz4664 10 днів тому

      ​@@TheDevWorldbySergioLema I am looking the next video (4 Easy Steps to Deploy ...) and I left a similar comment there. Really, it's a kind of AHAAA moment for me. thank´s again!

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  10 днів тому +1

      Thanks again!

  • @user-vg1rk1ep3s
    @user-vg1rk1ep3s Рік тому

    this video is helpful alot

  • @gamerpinguin007
    @gamerpinguin007 10 місяців тому

    thanks, it helps a lot

  • @user-is1nc9ni9e
    @user-is1nc9ni9e Рік тому +1

    Inbound rules part is very helpfull.

  • @rafaelramirez8820
    @rafaelramirez8820 Рік тому

    Thanks teacher

  • @Domzheritcy
    @Domzheritcy Рік тому +2

    Please continue make videos about Java and AWS

  • @johncerpa3782
    @johncerpa3782 Рік тому +4

    Video on VPC and networking would be great

  • @morigene
    @morigene 3 місяці тому

    Thank you. All network services in AWS are very helpful. please if possible please give it to us. thank you.

  • @khanhne19
    @khanhne19 11 місяців тому

    nice bros

  • @m.cheonsa
    @m.cheonsa Місяць тому

    Thank youuuu for the amazing video !
    Does anyone know from where i can get that ssh key before creating the instance?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Місяць тому

      You have to create it by your own, in your computer. Then upload it to AWS and assign it to the created EC2 instance.

  • @kirankumarkondapally237
    @kirankumarkondapally237 3 місяці тому

    Hi ,At 4.36 of the video you have used SSH keys , how to created that one please let us know .The one it shown is already created one you have imported.

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  3 місяці тому

      You have many ways to generate ssh keys. It depends on your OS. On windows, you have OpenSSH or Putty. On Linux or MacOS, you have ssh-keygen.

  • @user-sf6rr5fq4i
    @user-sf6rr5fq4i 9 місяців тому

    Thanks for the video. While I am trying to start ec2 instance using public ip address from local terminal. Connection is failing. Even ping to public ip is not working. can you suggest what would be failing ?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  9 місяців тому

      Check your security group. I must at least accept the port 22 for SSH and port 80 for ping.

  • @makilles7479
    @makilles7479 Рік тому

    Hi! Your video is excellent and is helping me a lot during my final project at college. However, I can't run the command "mvn" on my terminal (command not found). I also have a maven spring boot project, but I don't get what I did wrong. Would you help me, please?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому

      Thanks. The "mvn" command is the Maven command. If you don't have it installed in your EC2 image, you can also use the Maven Wrapper in many Spring Boot projects (which doesn't need to install).

  • @muadgra3545
    @muadgra3545 3 місяці тому

    I encountered problems (I'm using windows), you can also use EC2 console to connect

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  3 місяці тому

      Yes, the AWS console is very useful, as you don't need to configure your computer

  • @weixiangng8279
    @weixiangng8279 6 годин тому

    is aws ec2 from aws free tier?

  • @zhanglijunshao3310
    @zhanglijunshao3310 Рік тому

    when you import key pair, how did you get the content?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому +1

      it's the public part of my SSH key. You can easily find how to generate SSH keys here: www.google.com/search?q=create+ssh+key

  • @mykyta1235
    @mykyta1235 3 місяці тому

    thanks, great content

  • @MarselGaisin
    @MarselGaisin Рік тому

    After creating an application in Elastic Beanstalk, an error appears "The instance profile aws-elasticbeanstalk-ec2-role associated with the environment does not exist." Why is this happening?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому +1

      The video is not about Elastic Beanstalk. I haven't used Elastic Beanstalk for a while, I can't help you. Maybe if somebody else see the comment and knows the answer...

  • @carlosblinf
    @carlosblinf Рік тому +1

    Sergio, video de VPC !!

  • @burcutas1647
    @burcutas1647 10 місяців тому

    When I run the demo command in the terminal 08:00 , I get the following error:
    " 'demo' is not recognized as an internal or external command,
    operable program or batch file. "
    What can I do for it? Can you help?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  10 місяців тому

      😂 Sorry, demo is the name of the folder where I run the commands. My terminal displays it in another colour. It displays first the folder where I'm running the commands.

  • @kelvinboateng5445
    @kelvinboateng5445 2 місяці тому

    how do i add environment variables

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  2 місяці тому

      The best way is to add them when creating the EC2 image, or in the startup script.

  • @oss2046
    @oss2046 9 місяців тому

    Is it possible to do the same but with a war file instead of a jar file?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  9 місяців тому

      With a war file, you nees to first install a web server like Tomcat or Glassfish. The rest is the same (EC2 creation, security groups, VPN...)

  • @bruno.theoret
    @bruno.theoret 4 місяці тому

    Merci pour la vidéo Sergio. Tu crée une nouvelle instance EC2 pour le CI/CD, mais comment arrêter, effacer ton ancienne instance et transférer les requêtes vers la nouvelle vm pour ne pas utiliser trop de ressources lors du déploiement?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  4 місяці тому

      Merci pour ton commentaire Bruno. Là tu parles d'un cas plus avancé. En utilisant uniquement EC2, tu peux réussir ça en mettant un Load Balancer devant ton instance EC2. Quand tu crée ta nouvelle instance, il faudra la déclarer dans le Load Balancer. Et quand ru supprime l'ancienne, elle sera automatiquement supprimée du Load Balancer. Et le Load Balancer se chargera de rediriger le traffic d'une instance à l'autre.

  • @naziashaikh998
    @naziashaikh998 4 місяці тому

    The worst part is some things are already configured at tutors end, like console, terminal etc, and we are not sure how did tutor set them up in first place ;( . also, having lengthy commands pasted in description would make it easier for us to simple copy paste and do the job :)

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  4 місяці тому

      Sorry for not copy-past the commands on the description, but UA-cam don't render well some commands as it thinks it's some Script injection attack.
      The only thing I have previously configured, is the aws configure to create a profile connected to my AWS account. You can check how to do it here: docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-using-profiles

  • @prjvnd
    @prjvnd Рік тому

    Can the REST API's be accessible outside the region of EC2 ? I mean are the REST API's global ?

  • @rauchrodrigues272
    @rauchrodrigues272 Рік тому

    i wish if ur instructions were simpler on where did you run your startup code how to make ssh etc

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому

      Sorry, I assumed you already have some knowledge about bash scripting. Tell me your doubts, I may guide you with some resources or links.

  • @sachinthanaaluvihare7961
    @sachinthanaaluvihare7961 6 місяців тому +2

    If you get Permission denied (publickey,gssapi-keyex,gssapi-with-mic) when tring to ssh to ec2-user, just run chmod 400 on the pem file and try again

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  5 місяців тому +1

      Great advice!

    • @charlygarcia8223
      @charlygarcia8223 5 місяців тому

      How do you do this on windows CMD?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  5 місяців тому

      The goal of those commands is to run them from a CI/CD platform like GitlabCI. I've never used Windows on a CI/CD platform.
      But the AWS CLI is the same for Windows. You can check the installation guide in the official AWS Console page.

    • @anmarhammadi7471
      @anmarhammadi7471 3 дні тому

      oh right so we should be using the AWS cli here not windows CMD prompt. I think a few people are confused as to what shell was used in this video to run the command ssh ec2-user@blablabla

  • @naziashaikh998
    @naziashaikh998 4 місяці тому

    what terminal did he open?

  • @hasanmhdamin6076
    @hasanmhdamin6076 Рік тому

    Hi, I have connected to the server using ssh ec2-user@MY_IP
    it was success, and I've installed java.
    but when I tried to upload the JAR file I get this error:
    ED25519 key fingerprint is SHA256:XXXXXXXXXXX.
    This key is not known by any other names
    Are you sure you want to continue connecting (yes/no/[fingerprint])?
    and when I click yes, I get this error:
    Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
    Connection closed

    • @exerazor1911
      @exerazor1911 Рік тому

      i was having the same error, make sure that you are running the scp command on your local machine and not while connected to the ec2 instance :)

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому

      You must use the same user ec2-user when copying the JAR file, "scp file.jar ec2-user@MY_IP:/home/ec2-user/"

  • @alexanderayala-palacin5723
    @alexanderayala-palacin5723 5 місяців тому +2

    I created the vpc, ssh key, security group, the instance, followed everything in the video, and when I went to my terminal and did ssh ec2-user@, I got the error: Permission denied (publickeymgssapi,keyex,gssapi-with-mic). Anybody else?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  5 місяців тому

      Did you linked your ssh key to the EC2 instance?

    • @anmarhammadi7471
      @anmarhammadi7471 3 дні тому

      Exact same happened to me. Will rewatch the video in case I missed a step.

    • @anmarhammadi7471
      @anmarhammadi7471 3 дні тому

      watched the video again and got stuck at the same part

    • @anmarhammadi7471
      @anmarhammadi7471 3 дні тому

      I suppose which terminal should we be using? I think it might be the AWS cli? I'll try this now

  • @kanagasingamdanushan3701
    @kanagasingamdanushan3701 Рік тому +1

    Why can't access end points after closed the terminal?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому

      In my case, I run the Spring Boot application in the terminal, not in a background task. If I close the terminal which is running the application, it stops.
      For production ready applications, you should configure the startup of your application in the User Details script. This way, it's running as soon as the instance is up.

    • @shubhamjain5889
      @shubhamjain5889 3 місяці тому

      @@TheDevWorldbySergioLema Can you please share the details. How to do this?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  3 місяці тому

      It's the script I write into the UserDetails field in the video.

  • @rmcf3972
    @rmcf3972 2 місяці тому

    Is there a free aws for spring boot?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  2 місяці тому +1

      There are free Linux servers in AWS for one year. You can run whatever you want on them.

  • @welbe9436
    @welbe9436 Рік тому

    how did you add ssh key and what is ssh key, where to find that?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому

      An SSH keys is like a username/password to let your computer connecter to another computer via the port 22.
      You can generate them with ssh-keygen, putty or other tools.
      You must first generate a public/private key in your computer, then upload in the Key Pairs section of AWS the public one. Then, you can connect to the EC2 instances which have your Key Pair.

    • @mrowox
      @mrowox Рік тому +1

      @@TheDevWorldbySergioLema I have generated my key-pair, uploaded the public one to was and I still cannot connect. the error is `Permission denied (publickey,gssapi-keyex,gssapi-with-mic).`

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому

      Maybe your SSH key has permissions too open. Maybe the route to your SSH key is not the default one and your SSH agent can't find it. Check this link and try add the verbose option to see more details about the error: askubuntu.com/questions/311558/ssh-permission-denied-publickey

  • @HaoTran-bq7sh
    @HaoTran-bq7sh Рік тому

    how to deploy database

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому

      I didn't made a video about that, because it's just going to RDS, select the database, select the instance type, the amount of memory, and that's all

  • @nirangasithara
    @nirangasithara 8 місяців тому

    How did you make the SSH key ?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  8 місяців тому +1

      With ssh-keygen. For you, it will depend on your OS: docs.oracle.com/en/cloud/cloud-at-customer/occ-get-started/generate-ssh-key-pair.html#GUID-8B9E7FCB-CEA3-4FB3-BF1A-FD3406A2432F

    • @nirangasithara
      @nirangasithara 8 місяців тому

      @@TheDevWorldbySergioLema thank you. As an alternative I can use the pem file too. Right ?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  8 місяців тому +1

      I'm not sure about this. I would say no, but I've never tried.

  • @elitemiro
    @elitemiro Рік тому

    how to keep it running even after ssh session is terminated and my pc is shutdown? the app shuts down after a while

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому +1

      You can simply run it in background. Add the & symbol at the end of the command, and it will run in the background. Or create a screen and run it in the screen. Either way, when closing the SSH session, the application still runs.

    • @elitemiro
      @elitemiro Рік тому

      @@TheDevWorldbySergioLema it still shuts down when i close the terminal i need to run like a dedicated server

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому +1

      I'm not sure about what you mean about '"close the terminal". When running the server, you must add the "&" symbol at the end of the command. Then, you should have the terminal free to continue. Exploring the processes, ps -a, you should see the previous server running. Then, close the SSH connection and the server must continue to run.
      If the "&" symbol doesn't work, try using a screen (linuxize.com/post/how-to-use-linux-screen/).

    • @elitemiro
      @elitemiro Рік тому +1

      @@TheDevWorldbySergioLema thanks a lot the screen worked like a charm

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Рік тому +2

      I use it every time a need a long running task in a distance server.

  • @40ozhemlock
    @40ozhemlock 8 днів тому

    Sorry I'm dumb. When you say "and go to a terminal" (to connect to the instance). Do you mean just the command line on my local machine? Or are you talking about something in AWS? Doesn't AWS provide like 3 different ways within the console to connect to the instance? What do you mean when you say "and go to a terminal"?

    • @40ozhemlock
      @40ozhemlock 8 днів тому

      tried it from the command line.... permission denied....

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  8 днів тому

      Go to your local machine terminal. But you need to configure it before. Check here how to do it: docs.aws.amazon.com/cli/v1/userguide/cli-chap-configure.html

    • @40ozhemlock
      @40ozhemlock 2 дні тому

      @@TheDevWorldbySergioLema So I have made a lot of progress. Got a JAR file of my app onto the Linux Ec2. But when I run it, it doesn't pick up the properties from my properties file so I can't make the MYSQL DB connection. It keeps acting like it's trying to connect with root@... , But I have a ${DBUSERNAME} variable (and PW and URL) in my props file and I CANNOT get the app to pick those values up and connect with that. ANY ideas bro?

  • @alexandersepulveda5020
    @alexandersepulveda5020 Рік тому

    nube*

  • @thomasfang5156
    @thomasfang5156 7 місяців тому

    those kind of tutorial create more confuse