CI/CD from Github to AWS EC2 Step by Step | Node.js Express Backend API as an Example

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

ความคิดเห็น • 141

  • @qamarstationwala7538
    @qamarstationwala7538 2 ปีที่แล้ว +15

    man wrote out a package.json file by hand. what a boss

    • @bob-pk2ly
      @bob-pk2ly 2 ปีที่แล้ว

      LOL yeah.

    • @5906646
      @5906646 6 หลายเดือนก่อน

      vs code has intelisense of package.json properties. It's not a big deal.

  • @ethanjones3167
    @ethanjones3167 หลายเดือนก่อน

    Thank you for this. I had some issues but ended up running the Linux 2023 instance type instead and it worked beautifully.

  • @4azgin683
    @4azgin683 2 ปีที่แล้ว +4

    Thx i was searching for hours before finding this perfectly well made AND always working tutorial, big love from an french dev

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      I’m glad that u found it helpful 😊

  • @MpampisVovos-zc8cz
    @MpampisVovos-zc8cz 7 หลายเดือนก่อน

    Your voice is very calming, i love it

  • @lizzigibson2927
    @lizzigibson2927 ปีที่แล้ว

    Felix never lets me down! 😀

  • @ikeriebenezer6725
    @ikeriebenezer6725 2 ปีที่แล้ว +1

    the best video so far.
    thanks buddy

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว +1

      Glad that you found it helpful :)

  • @alimulrazi8251
    @alimulrazi8251 2 ปีที่แล้ว +1

    Thanks for your nice video. First-time deployment is successful but the next time shows this error "The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems." Then I fixed this error following your other video but it works for one time then while I deploy next time it shows the same error.

  • @xiaocuizhang6879
    @xiaocuizhang6879 ปีที่แล้ว

    thanks for the sharing, and looking forward to your more videos on code pipeline

  • @jefftan1098
    @jefftan1098 3 ปีที่แล้ว +3

    I like the details steps, awesome video!

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว +1

      Glad that it helped 👍

  • @Ixtinkt
    @Ixtinkt 2 ปีที่แล้ว +4

    I've got a message after the first successful deployment saying "The script application_stop.sh is not executable". After digging in deeper for a couple of hours I figured out that it is caused by sudo chmod -R 777 /home/ec2-user/express-app. So I put another command after this one sudo chown -R ec2-user:ec2-user /home/ec2-user/express-app/ and it started working fine. Besides that I replaced nvm install node with nvm install 16 because node 18 on EC2 under Linux amazon has issues

  • @j.k.ravshanovich
    @j.k.ravshanovich ปีที่แล้ว

    Kudos to you! Finally resolved my issues! 🥳🥳🥳Many thanks! 🙏🙏🙏

    • @FelixYu
      @FelixYu  ปีที่แล้ว

      Glad that u found it helpful mate!!

  • @pradyumnagayake4825
    @pradyumnagayake4825 2 ปีที่แล้ว +1

    Thank Felix for this video, It helped me a lot

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว +1

      I am glad that u found it helpful 👍

  • @Amanda-qu9uw
    @Amanda-qu9uw 3 ปีที่แล้ว +1

    It would be helpful if a newer video was made with your fixes rather than have bubble comments pop up that I don't fully understand yet. Other than that great tutorial! Thank you :)

  • @5906646
    @5906646 6 หลายเดือนก่อน

    You have done wonderful work! Thanks a lot!

  • @SaadAbbasi
    @SaadAbbasi ปีที่แล้ว

    Thanks for the best tutorial ever, though i have to install and run by myself *first* time 🙂

  • @icarochenel
    @icarochenel 3 ปีที่แล้ว +7

    Thank you for this video. Straight to the point and really well explained

  • @azil2024
    @azil2024 2 ปีที่แล้ว

    you are the best, great example

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      Glad that it’s helpful 👍

  • @TheRishith
    @TheRishith 3 ปีที่แล้ว +1

    You are great , very detailed step by step

  • @TheLiberty007
    @TheLiberty007 2 ปีที่แล้ว

    You're awesome Felix.

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      glad that it is helpful 👍

  • @SergioGama
    @SergioGama 2 ปีที่แล้ว

    Clear and straight to the point! congratulations and thanks!

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      Glad that u found it helpful!!

  • @banzaiwhoop8289
    @banzaiwhoop8289 7 หลายเดือนก่อน

    you are just amazing :)

  • @srinivas5324
    @srinivas5324 3 ปีที่แล้ว +2

    Thank you so much for referring this video @ Felix . Can you do a video on Automation Testing after the Code Pipeline is completed in AWS.

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว +2

      i have never done it in the past, but i will look into ti 👍

    • @srinivas5324
      @srinivas5324 3 ปีที่แล้ว

      @@FelixYu Thank you so much 👍👍

  • @niksdope
    @niksdope ปีที่แล้ว +4

    Hey Felix, great video. Just wanted to ask is there any way to see the app.out.log logs in the EC2 instance anywhere? If not, where would you go to see them?

  • @amitkariyani7261
    @amitkariyani7261 2 ปีที่แล้ว

    thank you for posting this video. easy and to the point

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      Glad that u found it helpful!!

    • @amitkariyani7261
      @amitkariyani7261 2 ปีที่แล้ว

      @@FelixYu I have successfully Created pipeline using CodeDeploy but when I am accessing my URL:3000 throws error unable to connect.
      what could be the reason for the error

  • @manishaverma81
    @manishaverma81 2 ปีที่แล้ว

    Thank you , it's a great video . Please help in future by making such type of other videos. Thanks again 😇

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว +1

      Glad that it’s helpful :)

    • @manishaverma81
      @manishaverma81 2 ปีที่แล้ว

      @@FelixYu Sir please explain why we skipped the build stage with explanation please🙏

  • @dominikwozniak4317
    @dominikwozniak4317 3 ปีที่แล้ว +1

    Great video! I've got one quesiton, how to provide env variable to ec2 instance?

  • @minhlephancong8335
    @minhlephancong8335 3 ปีที่แล้ว +1

    thank you for your straight to point tut, if i have a file contains environment variables, like .env, how can i import it

  • @AK-rz6rw
    @AK-rz6rw 2 ปีที่แล้ว

    got some clarity for ci/cd in aws

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว +1

      Glad that it’s helpful

    • @AK-rz6rw
      @AK-rz6rw 2 ปีที่แล้ว

      Yes Felix, implemented . Hitting application page with port 3000 after deployment.. getting page not reachable...they to change inbound rules source to anywhere but not allowing to change and save as anywhere .. not sure whether due to free account restriction or not, checking that

  • @sanjibkumarjena5556
    @sanjibkumarjena5556 2 ปีที่แล้ว

    Very much helpful.. Thank you sir!!

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      glad that it is helpful

  • @mohammad9754
    @mohammad9754 2 ปีที่แล้ว

    legend thank you

  • @RobinSingh-ms3zt
    @RobinSingh-ms3zt 2 ปีที่แล้ว

    Thanks for this amazing tutorial.

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      Glad that it helped 👍

  • @vigneshtamizh4091
    @vigneshtamizh4091 5 หลายเดือนก่อน

    I am curious about how yml script file is taking automatically for deployment steps.

  • @DanlHb
    @DanlHb 2 ปีที่แล้ว

    Great job. I have a question. How I can handle firebase keys in EC2 to use Auth FireBase?

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว +1

      i suggest using the aws secrets manager service to store ur credentials and then add a policy to ur ec2 IAM role to allow ur EC2 access to the credentials

    • @DanlHb
      @DanlHb 2 ปีที่แล้ว

      @@FelixYu thanks a lot, I'm gonna investigate about that.

  • @ciroamore2129
    @ciroamore2129 3 ปีที่แล้ว

    Love your videos. I subscribed!

  • @satyapriyaiyengar3918
    @satyapriyaiyengar3918 2 ปีที่แล้ว +2

    Thank you very much for the video. I tried it and it was successful however i had to manually install and run the node on my EC2 instance else it shows connection refused error on my browser. What wrong am I doing?

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว +1

      Hmm that’s weird..have u tried to copy the source code in the description section and modify it accordingly?? It might be caused by a typo or something

    • @satyapriyaiyengar3918
      @satyapriyaiyengar3918 2 ปีที่แล้ว

      @@FelixYu Thank you very much for the reply. I haven't tried, but I did cross-check with the source code in the description section after writing the code. Everything matched. Let me try copying. Maybe I must have missed something. I will update you accordingly. Thanks once again.

  • @ttaylor9916
    @ttaylor9916 หลายเดือนก่อน

    Thanks!

  • @RV-iw8sr
    @RV-iw8sr 3 ปีที่แล้ว +1

    firstly i followed the steps and its succesfully deployed.
    but after restarting instance deployment fails again...it shows script error in application_stop.sh
    can you please tell why this is happening?
    thankyou.

  • @a不死肥的技术宅
    @a不死肥的技术宅 3 ปีที่แล้ว

    easy to understand. thank u so much.

  • @isaacbotwe4136
    @isaacbotwe4136 2 ปีที่แล้ว +1

    Hey felix, i love the tutorial but my project has multiple environment variables, how do I add environment variables

    • @mohammad9754
      @mohammad9754 2 ปีที่แล้ว +2

      Use AWS parameter store or AWS secret manager to store your variables and then create a shell script import_secrets.sh that fetches secrets via the CLI and sticks them in a .env file at the project root. That was my solution anyway

  • @himanshunegi9970
    @himanshunegi9970 3 ปีที่แล้ว

    thanks bro for this video, keep doing...

  • @advitpunia2155
    @advitpunia2155 3 ปีที่แล้ว

    AWESOME Dude !!

  • @techie_bhuvi
    @techie_bhuvi 3 ปีที่แล้ว +1

    Here you had used yml file ..can we use docker image and then deploy in similar way?

  • @jonathantea913
    @jonathantea913 2 ปีที่แล้ว

    omg i love you

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      Glad that u found it helpful mate 👍

  • @ritikasrivastava9417
    @ritikasrivastava9417 2 ปีที่แล้ว

    Hey the pipeline got created successfully. I don't have the code or the node.js application on my local machine. Is that the reason when m trying to access the website ( mentioning port3000) it show the site can't be reached

  • @SaadAbbasi
    @SaadAbbasi ปีที่แล้ว

    BTW! .YML not working , every time i have to do all the steps by myself ,nvm, node installation , packages installation , app runing etc..

  • @sense3d
    @sense3d 9 หลายเดือนก่อน

    Thank you

  • @jlaleandro
    @jlaleandro 2 ปีที่แล้ว

    100% ok!!!

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      👍👍

  • @mounirbennacer344
    @mounirbennacer344 ปีที่แล้ว

    hey Felix, thank you for this tutorial, very helpful,
    if you don't mind, i would like to know your approach to a TypeScript project, would you rather build the project with GitHub Action and send that dist folder to your EC2 instance, or send the whole project to EC2 instance and build there?

    • @FelixYu
      @FelixYu  ปีที่แล้ว +1

      I personally think it’s better to build ur project in ur CI/CD pipeline first and just send the dust folder to ur ec2. This way u can catch any build errors and it will not affect ur prod instance.

    • @mounirbennacer344
      @mounirbennacer344 ปีที่แล้ว

      @@FelixYu could you please make a video about this topic, there is no great explanation on how to handle this topic, i've discovered recently the use of github artifacts between jobs.

    • @FelixYu
      @FelixYu  ปีที่แล้ว

      @@mounirbennacer344 i have a video on how to use CodeBuild to build an angular (TypeScript) project. if can reference this and see if u can combine this with CodeDeploy in this video
      th-cam.com/video/AMSdM2dj_eI/w-d-xo.html

  • @kemekenneth
    @kemekenneth 2 ปีที่แล้ว

    Thank you for the video. I believe all 3 scripts run on every update, download nvm, install node. If that's the case, is it necessary? Can't node be installed once with ec2 script like you did codedeploy agent?

  • @yazeedZz2000
    @yazeedZz2000 3 ปีที่แล้ว

    what command should I use if I want to deploy a nestjs app?

  • @indiratania8826
    @indiratania8826 2 ปีที่แล้ว

    When I access the public IPv4 DNS, it says This site can't be reached. Why is that, sir?

  • @advitpunia2155
    @advitpunia2155 3 ปีที่แล้ว

    one request if you can create one video on multiple stages pipeline for node.js

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว

      thanks for the suggestion....i can def look into it 👍

  • @akashjohirul9409
    @akashjohirul9409 ปีที่แล้ว

    Does this server restarts if unhandalled rejection occured?

  • @vishalgupta2869
    @vishalgupta2869 2 ปีที่แล้ว

    Nice

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      Thanks mate!!

  • @JahidGamer
    @JahidGamer 3 ปีที่แล้ว +1

    Thank you so much brother. Can I perform the whole process in a free-tier account? Will it cost money?

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว +5

      CodeDeploy and CodePipeline are free. if the EC2 type u are using is free-tier eligible, everything is free. no cost!!

  • @mehmetselcukcandan2134
    @mehmetselcukcandan2134 3 ปีที่แล้ว +1

    How can we deploy our project with a special url?

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว

      an EC2 alone does not allow u to have an url for your system. you will need route53 and a load balancer to point to a target group that contains ur ec2 instance(s). if u dont want to configure all this by urself, i recommend using elastic beanstalk. check out the video below:
      th-cam.com/video/YJvXHr69AHg/w-d-xo.html

  • @Aeyzaz
    @Aeyzaz 2 ปีที่แล้ว

    How to deploy without setting 777 permissions to the directory, the default ownership is root. Anyway code-deploy runs all the scripts in ec2-user environment?

  • @satyasimhasriperambuduru6361
    @satyasimhasriperambuduru6361 3 ปีที่แล้ว +1

    I see 2 roles were created but only code deploy role is used in the pipeline. Could you please tell me where the other role (EC2codedeployrole)is used? Am i missing something

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว

      that is being used by the EC2 instance (14:15 of the video).

    • @satyasimhasriperambuduru6361
      @satyasimhasriperambuduru6361 3 ปีที่แล้ว +1

      @@FelixYu Thank you so much..

  • @MohdDanish-kv8ry
    @MohdDanish-kv8ry 3 ปีที่แล้ว +1

    Hey felix excellent explanation,. In your tutorial, you just wrote node app.js and your server started.
    I have 2 separate folders (frontend and backend) in the root . So In development I have to go into each folder and run it separately. what changes do i need to make to deploy ? please reply please...

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว +2

      in ur application_start.sh file u can just cd into each individual folder and issue the commands to start it (similar to this line here)
      github.com/felixyu9/nodejs-express-on-aws-ec2/blob/main/scripts/application_start.sh#L7
      if you wish to host the frontend on s3, which is a pretty common practice, refer to this video for the CI/CD:
      th-cam.com/video/AMSdM2dj_eI/w-d-xo.html

    • @raghupathym25
      @raghupathym25 3 ปีที่แล้ว

      I have a Reactjs client container, Nodejs server container and docker compose to connect them. Is there any github workflow to push them into ECR and ECS?

    • @shubhamshastri7409
      @shubhamshastri7409 2 ปีที่แล้ว

      @@raghupathym25 now we have new technology to do it using docker context , thank-you

  • @PonomarenkoO
    @PonomarenkoO 2 ปีที่แล้ว

    thx!

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว +1

      You are welcome!!

  • @sunny25984
    @sunny25984 2 ปีที่แล้ว

    Hey Felix..Great one !!! I have one problem.. when I run npm install in VSC,I get the below error
    npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    the spelling of the name, or if a path was included, verify that the path is correct and try again.

    • @johncross116
      @johncross116 2 ปีที่แล้ว +3

      Make sure that you have npm installed, and specified in your PATH. You can also skip this part of the tutorial, it's not necessary to run the application locally.

  • @ShubhamSharma-or9fn
    @ShubhamSharma-or9fn 3 ปีที่แล้ว

    Thank you so much..

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว

      Glad that it helped :)

  • @lakshmankashyap4690
    @lakshmankashyap4690 2 ปีที่แล้ว

    Hi , everything done successfully but code showing updated on shh app folder but not showing udpated on ip addresss

    • @kartikgupta9654
      @kartikgupta9654 2 ปีที่แล้ว

      Hey i'm facing the same problem, did you manage to fix it ?

  • @rawalhardik143
    @rawalhardik143 2 ปีที่แล้ว

    How can I pass .env variables for example mongoURI etc? Please advise.

    • @javascript_developer
      @javascript_developer 2 ปีที่แล้ว

      .evn
      PORT=80
      server.ts
      const dotenv = require('dotenv');
      dotenv.config();
      and use it like. `process.env.PORT`
      like this.

  • @ShubhamSharma-or9fn
    @ShubhamSharma-or9fn 3 ปีที่แล้ว

    If you can please make video on aws timestream, that would be really great..

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว

      I have never used timestream before but I can look into it

  • @genos2719
    @genos2719 3 ปีที่แล้ว

    is there a way to trigger deploy if merge to production branch?

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว +1

      i think u just needa change the branch name from main to ur production branch name at 20:55 of the video

  • @kartikgupta9654
    @kartikgupta9654 2 ปีที่แล้ว

    Hey Felix, i ran into a problem. In my case the pipeline was working fine, but i modified something and pushed the code to github and the code is not being updated on the instance. I checked my pipeline, it is showing the latest commit but code isn't updated.

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      Did u check ur GitHub repo, the main branch and see the updates there?

  • @billzhou8686
    @billzhou8686 3 ปีที่แล้ว

    👍👍👍

  • @bearisaur
    @bearisaur 3 ปีที่แล้ว +1

    This only seems to work the first time, everytime the application_script script is ran it fails, and I have to manually remove the codedeploy agent. Any tips?

    • @bearisaur
      @bearisaur 3 ปีที่แล้ว +2

      I should add the error I get is: Script at specified location: scripts/application_stop.sh run as user ec2-user failed with exit code 1

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว +1

      hmmm...thats weird. it didnt seem to happen to me but i know that ApplicationStop is a special hook. it uses the script from ur previous build to run this hook (before the BeforeInstall hook where it pulls ur updated code). i have seen a lot of posts online abt CodeDeploy being unstable so i think this might happen when ur previous build failed or when the instance was not healthy?? lmk if this problem persists; i will try to create a video using jenkins/codebuild for the deployment instead (should be more stable)!!

    • @bearisaur
      @bearisaur 3 ปีที่แล้ว

      @@FelixYu yeah, I noticed it uses the code from the previous deployment. I was never able to get it working consistently, it seems like pkill exits with code 1, which is not a graceful exit.

    • @bearisaur
      @bearisaur 3 ปีที่แล้ว

      I also recreated the instance and it had successful builds before, so that wasn't the issue.

    • @tanmayjain2865
      @tanmayjain2865 2 ปีที่แล้ว

      Hey @bigpog , I am facing the same error, can you tell me how did you resolve this error?

  • @rohitsingh4313
    @rohitsingh4313 3 ปีที่แล้ว

    Hey can u help me. i have followed your code but my app is not running on port 3000 or 3001

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว

      its hard to debug without any info/details. look at this video first and see if any of the solutions can fix it:
      th-cam.com/video/sXZVkOH6hrA/w-d-xo.html

  • @jlaleandro
    @jlaleandro 2 ปีที่แล้ว

    Obrigado, muito bom, Abraços.

  • @lirikdankuncigitar6093
    @lirikdankuncigitar6093 3 ปีที่แล้ว

    Hello Felix.
    This works for js.
    I wanna use your tutorial on my app build on express + typescript. How can i compile my typescript file first?
    Great tutorial btw.

    • @FelixYu
      @FelixYu  2 ปีที่แล้ว

      i think u just needa add the typescript compilation commands right before the express build command

  • @narendravishwakarma1793
    @narendravishwakarma1793 3 ปีที่แล้ว

    Hey, can you please tell me what is use of creating appspec.yml file in the project folder. What is it being used for?

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว +3

      when CodeDeploy runs, the first thing it looks for is the appspec.yml file (the name has to be "appspec.yml" and it needs to be in the root directory of the project. this file specifies things like the os, file location and hooks/actions the pipeline needs to take for the deployment (see source code below). for example, line 2 tells the pipeline to us a linux operating system to run the deployment and line 16 tells the pipeline to run the "scripts/application_start.sh" to start the application, etc.
      github.com/felixyu9/nodejs-express-on-aws-ec2/blob/main/appspec.yml

    • @narendravishwakarma1793
      @narendravishwakarma1793 3 ปีที่แล้ว +2

      @@FelixYu thanks for replying instantly 😀

    • @shamshid
      @shamshid 3 ปีที่แล้ว

      Make a video on Gh Actions to EC2

  • @owenzmortgage8273
    @owenzmortgage8273 ปีที่แล้ว

    java Developer? Java Developer does not has to do operation cloud engineer job, do you get paid twice to do both developer and DEVOPS, cloud engineer JOb?

  • @vinayjain1739
    @vinayjain1739 3 ปีที่แล้ว

    Beforeinstall script not working.

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว

      make sure the file location u specify under BeforeInstall in the appspec.yml file is correct and the script is actually in that location. try to clone this repo and modify it as needed:
      github.com/felixyu9/nodejs-express-on-aws-ec2

  • @jinkahari
    @jinkahari 3 ปีที่แล้ว

    Thank you very much for making video. Can you please make video CI/CD from Github to AWS ECS or EKS deployment.

    • @FelixYu
      @FelixYu  3 ปีที่แล้ว

      I’ll add that to the list 👍

  • @hazartilirot1014
    @hazartilirot1014 3 ปีที่แล้ว

    If you're unconcern in watching how the bloke is typing just start watching from 5:39 - for the sake of your life span!

  • @anweshachakraborty1881
    @anweshachakraborty1881 2 ปีที่แล้ว

    I tried this but not working, showing the below error, can you help me
    AWS CodeDeploy does not have the permissions required to assume the role arn:aws:iam::580676505778:instance-profile/codedDeployed.

  • @abderrahimbounyane2039
    @abderrahimbounyane2039 3 ปีที่แล้ว

    Thank you very much

  • @devsecops6406
    @devsecops6406 2 ปีที่แล้ว

    When I access the public IPv4 DNS, it says This site can't be reached. Why is that, sir?