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.
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
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 :)
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?
@@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
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
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
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?
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
@@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.
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.
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
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
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?
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.
@@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.
@@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
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?
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
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?
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
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...
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
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?
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.
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.
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.
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?
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)!!
@@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.
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
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.
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
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?
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
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.
man wrote out a package.json file by hand. what a boss
LOL yeah.
vs code has intelisense of package.json properties. It's not a big deal.
Thank you for this. I had some issues but ended up running the Linux 2023 instance type instead and it worked beautifully.
Thx i was searching for hours before finding this perfectly well made AND always working tutorial, big love from an french dev
I’m glad that u found it helpful 😊
Your voice is very calming, i love it
Felix never lets me down! 😀
the best video so far.
thanks buddy
Glad that you found it helpful :)
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.
thanks for the sharing, and looking forward to your more videos on code pipeline
I like the details steps, awesome video!
Glad that it helped 👍
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
Kudos to you! Finally resolved my issues! 🥳🥳🥳Many thanks! 🙏🙏🙏
Glad that u found it helpful mate!!
Thank Felix for this video, It helped me a lot
I am glad that u found it helpful 👍
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 :)
You have done wonderful work! Thanks a lot!
Thanks for the best tutorial ever, though i have to install and run by myself *first* time 🙂
Thank you for this video. Straight to the point and really well explained
you are the best, great example
Glad that it’s helpful 👍
You are great , very detailed step by step
You're awesome Felix.
glad that it is helpful 👍
Clear and straight to the point! congratulations and thanks!
Glad that u found it helpful!!
you are just amazing :)
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.
i have never done it in the past, but i will look into ti 👍
@@FelixYu Thank you so much 👍👍
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?
thank you for posting this video. easy and to the point
Glad that u found it helpful!!
@@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
Thank you , it's a great video . Please help in future by making such type of other videos. Thanks again 😇
Glad that it’s helpful :)
@@FelixYu Sir please explain why we skipped the build stage with explanation please🙏
Great video! I've got one quesiton, how to provide env variable to ec2 instance?
thank you for your straight to point tut, if i have a file contains environment variables, like .env, how can i import it
got some clarity for ci/cd in aws
Glad that it’s helpful
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
Very much helpful.. Thank you sir!!
glad that it is helpful
legend thank you
Thanks for this amazing tutorial.
Glad that it helped 👍
I am curious about how yml script file is taking automatically for deployment steps.
Great job. I have a question. How I can handle firebase keys in EC2 to use Auth FireBase?
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
@@FelixYu thanks a lot, I'm gonna investigate about that.
Love your videos. I subscribed!
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?
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
@@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.
Thanks!
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.
easy to understand. thank u so much.
Hey felix, i love the tutorial but my project has multiple environment variables, how do I add environment variables
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
thanks bro for this video, keep doing...
AWESOME Dude !!
Here you had used yml file ..can we use docker image and then deploy in similar way?
yes
omg i love you
Glad that u found it helpful mate 👍
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
BTW! .YML not working , every time i have to do all the steps by myself ,nvm, node installation , packages installation , app runing etc..
Thank you
100% ok!!!
👍👍
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?
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.
@@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.
@@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
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?
what command should I use if I want to deploy a nestjs app?
When I access the public IPv4 DNS, it says This site can't be reached. Why is that, sir?
one request if you can create one video on multiple stages pipeline for node.js
thanks for the suggestion....i can def look into it 👍
Does this server restarts if unhandalled rejection occured?
Nice
Thanks mate!!
Thank you so much brother. Can I perform the whole process in a free-tier account? Will it cost money?
CodeDeploy and CodePipeline are free. if the EC2 type u are using is free-tier eligible, everything is free. no cost!!
How can we deploy our project with a special url?
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
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?
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
that is being used by the EC2 instance (14:15 of the video).
@@FelixYu Thank you so much..
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...
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
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?
@@raghupathym25 now we have new technology to do it using docker context , thank-you
thx!
You are welcome!!
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.
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.
Thank you so much..
Glad that it helped :)
Hi , everything done successfully but code showing updated on shh app folder but not showing udpated on ip addresss
Hey i'm facing the same problem, did you manage to fix it ?
How can I pass .env variables for example mongoURI etc? Please advise.
.evn
PORT=80
server.ts
const dotenv = require('dotenv');
dotenv.config();
and use it like. `process.env.PORT`
like this.
If you can please make video on aws timestream, that would be really great..
I have never used timestream before but I can look into it
is there a way to trigger deploy if merge to production branch?
i think u just needa change the branch name from main to ur production branch name at 20:55 of the video
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.
Did u check ur GitHub repo, the main branch and see the updates there?
👍👍👍
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?
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
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)!!
@@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.
I also recreated the instance and it had successful builds before, so that wasn't the issue.
Hey @bigpog , I am facing the same error, can you tell me how did you resolve this error?
Hey can u help me. i have followed your code but my app is not running on port 3000 or 3001
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
Obrigado, muito bom, Abraços.
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.
i think u just needa add the typescript compilation commands right before the express build command
Hey, can you please tell me what is use of creating appspec.yml file in the project folder. What is it being used for?
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
@@FelixYu thanks for replying instantly 😀
Make a video on Gh Actions to EC2
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?
Beforeinstall script not working.
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
Thank you very much for making video. Can you please make video CI/CD from Github to AWS ECS or EKS deployment.
I’ll add that to the list 👍
If you're unconcern in watching how the bloke is typing just start watching from 5:39 - for the sake of your life span!
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.
Thank you very much
When I access the public IPv4 DNS, it says This site can't be reached. Why is that, sir?