How to Easily Deploy a Spring Boot Application to AWS EC2

Sdílet
Vložit
  • čas přidán 9. 07. 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
  • Věda a technologie

Komentáře • 130

  • @shashankbhat6184
    @shashankbhat6184 Před rokem +9

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před rokem

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

    • @shashankbhat6184
      @shashankbhat6184 Před rokem

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

  • @anthonycarella1779
    @anthonycarella1779 Před 3 měsíci

    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!

  • @santiagoibarbia3958
    @santiagoibarbia3958 Před 5 měsíci

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

  • @Apopjak
    @Apopjak Před rokem

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

  • @lukamarkac6706
    @lukamarkac6706 Před 9 měsíci

    Beautiful video, props bro!

  • @user-sl6ch8hv8f
    @user-sl6ch8hv8f Před 7 měsíci

    Explanation very clean and excellent, thank you

  • @mihailegorin2349
    @mihailegorin2349 Před rokem

    Thank you! Your video was very helpful for me

  • @pulato000
    @pulato000 Před rokem

    Cool, looking forward to another one

  • @bodyakov4483
    @bodyakov4483 Před rokem

    Great video, thank you!

  • @user-kh9xs5lq9p
    @user-kh9xs5lq9p Před 7 měsíci

    this tutorial is very helpful. thank you!

  • @ernestcronin8999
    @ernestcronin8999 Před 5 měsíci

    Excellent video. Thank you so much.

  • @maYoutubeTube
    @maYoutubeTube Před 8 měsíci

    Great video. Thank you

  • @programmierenabisz4664

    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 ;))

  • @MikeBrownphx
    @MikeBrownphx Před měsícem

    Great video.

  • @gamerpinguin007
    @gamerpinguin007 Před 10 měsíci

    thanks, it helps a lot

  • @user-vg1rk1ep3s
    @user-vg1rk1ep3s Před rokem

    this video is helpful alot

  • @rafaelramirez8820
    @rafaelramirez8820 Před rokem

    Thanks teacher

  • @user-is1nc9ni9e
    @user-is1nc9ni9e Před rokem +1

    Inbound rules part is very helpfull.

  • @kirankumarkondapally237
    @kirankumarkondapally237 Před 3 měsíci

    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  Před 3 měsíci

      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.

  • @m.cheonsa
    @m.cheonsa Před 2 měsíci

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před měsícem

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

  • @Domzheritcy
    @Domzheritcy Před rokem +2

    Please continue make videos about Java and AWS

  • @johncerpa3782
    @johncerpa3782 Před rokem +4

    Video on VPC and networking would be great

  • @khanhne19
    @khanhne19 Před 11 měsíci

    nice bros

  • @user-sf6rr5fq4i
    @user-sf6rr5fq4i Před 9 měsíci

    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  Před 9 měsíci

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

  • @morigene
    @morigene Před 4 měsíci

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

  • @makilles7479
    @makilles7479 Před rokem

    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  Před rokem

      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).

  • @zhanglijunshao3310
    @zhanglijunshao3310 Před rokem

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před rokem +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

  • @MarselGaisin
    @MarselGaisin Před rokem

    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  Před rokem +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...

  • @burcutas1647
    @burcutas1647 Před 10 měsíci

    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  Před 10 měsíci

      😂 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.

  • @oss2046
    @oss2046 Před 10 měsíci

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před 10 měsíci

      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...)

  • @prjvnd
    @prjvnd Před rokem

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

  • @mykyta1235
    @mykyta1235 Před 3 měsíci

    thanks, great content

  • @kanagasingamdanushan3701

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před rokem

      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 Před 4 měsíci

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před 4 měsíci

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

  • @hasanmhdamin6076
    @hasanmhdamin6076 Před rokem

    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 Před rokem

      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  Před rokem

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

  • @kelvinboateng5445
    @kelvinboateng5445 Před 2 měsíci

    how do i add environment variables

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před 2 měsíci

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

  • @welbe9436
    @welbe9436 Před rokem

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před rokem

      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 Před rokem +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  Před rokem

      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

  • @alexanderayala-palacin5723
    @alexanderayala-palacin5723 Před 5 měsíci +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?

  • @sachinthanaaluvihare7961
    @sachinthanaaluvihare7961 Před 6 měsíci +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  Před 6 měsíci +1

      Great advice!

    • @charlygarcia8223
      @charlygarcia8223 Před 6 měsíci

      How do you do this on windows CMD?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před 5 měsíci

      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 Před 8 dny

      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

  • @bruno.theoret
    @bruno.theoret Před 4 měsíci

    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  Před 4 měsíci

      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.

  • @elitemiro
    @elitemiro Před rokem

    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  Před rokem +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 Před rokem

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před rokem +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 Před rokem +1

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před rokem +2

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

  • @naziashaikh998
    @naziashaikh998 Před 5 měsíci

    what terminal did he open?

  • @naziashaikh998
    @naziashaikh998 Před 5 měsíci

    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  Před 4 měsíci

      Sorry for not copy-past the commands on the description, but CZcams 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

  • @rmcf3972
    @rmcf3972 Před 2 měsíci

    Is there a free aws for spring boot?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před 2 měsíci +1

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

  • @weixiangng8279
    @weixiangng8279 Před 6 dny

    is aws ec2 from aws free tier?

  • @muadgra3545
    @muadgra3545 Před 3 měsíci

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před 3 měsíci

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

    • @nietur
      @nietur Před 2 dny

      "This instance type is not supported for the EC2 serial console."

  • @nirangasithara
    @nirangasithara Před 8 měsíci

    How did you make the SSH key ?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před 8 měsíci +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 Před 8 měsíci

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před 8 měsíci +1

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

  • @40ozhemlock
    @40ozhemlock Před 14 dny

    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 Před 14 dny

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před 14 dny

      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 Před 8 dny

      @@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?

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před 2 dny

      Did you added those values (db username, password and url) to the EC2 environment variables?

    • @40ozhemlock
      @40ozhemlock Před 2 dny

      @@TheDevWorldbySergioLema Yeah I have

  • @carlosblinf
    @carlosblinf Před rokem +1

    Sergio, video de VPC !!

  • @rauchrodrigues272
    @rauchrodrigues272 Před rokem

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

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před rokem

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

  • @HaoTran-bq7sh
    @HaoTran-bq7sh Před rokem

    how to deploy database

    • @TheDevWorldbySergioLema
      @TheDevWorldbySergioLema  Před rokem

      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

  • @thomasfang5156
    @thomasfang5156 Před 7 měsíci +1

    those kind of tutorial create more confuse

  • @alexandersepulveda5020

    nube*