Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
19bc1fa
Update README.md
jipx Mar 20, 2023
87ff833
Update README.md
jipx Mar 20, 2023
583cd22
Update README.md
jipx Mar 20, 2023
dc48543
Create userData
jipx Mar 20, 2023
8863c64
Update README.md
jipx Mar 20, 2023
f6dc93d
Update README.md
jipx Mar 21, 2023
17440fa
Update README.md
jipx Mar 21, 2023
e0bafde
Update README.md
jipx Mar 21, 2023
4984f98
Update README.md
jipx Mar 21, 2023
26d0983
Update README.md
jipx Mar 21, 2023
bb9ec1e
Update app.js
jipx Mar 21, 2023
85ca9f9
Update deploy.yml
jipx Mar 21, 2023
3335564
Update deploy.yml
jipx Mar 21, 2023
7d96eeb
change version
jipx Mar 21, 2023
00b3a99
change
jipx Mar 21, 2023
69bde05
commitjipx
jipx Mar 21, 2023
79890ef
Update deploy.yml
jipx Mar 21, 2023
b3f739a
Update deploy.yml
jipx Mar 21, 2023
18b3d3b
test 3
jipx Mar 21, 2023
5eb7f0d
Merge branch 'main' of https://github.com/jipx/nodejs-aws-codedeploy-…
jipx Mar 21, 2023
d6f369f
update yaml
jipx Mar 21, 2023
1ee3473
test4
jipx Mar 21, 2023
7fb3079
Merge branch 'main' of https://github.com/jipx/nodejs-aws-codedeploy-…
jipx Mar 21, 2023
2fc05af
Update deploy.yml
jipx Mar 21, 2023
54c4c20
Update deploy.yml
jipx Mar 21, 2023
3bfb580
test5
jipx Mar 21, 2023
f3c9b2b
Merge branch 'main' of https://github.com/jipx/nodejs-aws-codedeploy-…
jipx Mar 21, 2023
73767e0
test6
jipx Mar 21, 2023
ac55d28
change home page css to style relative
jipx Mar 22, 2023
08d511e
test
jipx Mar 22, 2023
4f81610
change image size to fit the container
jipx Mar 22, 2023
74d1a7c
change random images
jipx Mar 22, 2023
db8c458
change random images
jipx Mar 22, 2023
65844a5
revert back
jipx Mar 22, 2023
4a14197
change random image
jipx Mar 22, 2023
7a7479f
add random to image selection
jipx Mar 22, 2023
263c5be
add random selection of image
jipx Mar 22, 2023
1ad19ff
chage to assumrole
jipx Mar 22, 2023
514c442
update yaml with permissions
jipx Mar 22, 2023
e6b2213
syn with repo
jipx Mar 22, 2023
d6fd928
change to version 7
jipx Mar 23, 2023
01d5137
version 8
jipx Mar 23, 2023
8fee9bb
change yml file to store credential instead of openID
jipx Mar 23, 2023
74b8cf8
correct yaml file error in alignment
jipx Mar 23, 2023
c8dd771
EC2 profile
jipx Mar 23, 2023
eccddc4
profile to EC2
jipx Mar 23, 2023
9fbfd94
Update app.js
jipx Mar 25, 2023
b4f8a61
Update app.js
jipx Mar 25, 2023
6ef2911
Update app.js
jipx Mar 26, 2023
1b45d4b
testing
jipx Mar 26, 2023
a9821f8
Merge branch 'main' of https://github.com/jipx/nodejs-aws-codedeploy-…
jipx Mar 26, 2023
36eed76
merge changes
jipx Mar 26, 2023
939113b
change version to 3.26.12.3334
jipx Mar 26, 2023
ec3daac
Update app.js
jipx Mar 26, 2023
6a90f9e
change version number
jipx Mar 26, 2023
0068f31
Merge branch 'main' of https://github.com/jipx/nodejs-aws-codedeploy-…
jipx Mar 26, 2023
bc275fe
change version number
jipx Mar 26, 2023
167de91
version numbner
jipx Mar 26, 2023
e9b2b1e
Update app.js
jipx Mar 26, 2023
b360c9e
change version
jipx Mar 26, 2023
23b774b
Merge branch 'main' of https://github.com/jipx/nodejs-aws-codedeploy-…
jipx Mar 26, 2023
277cbc8
greeting
jipx Mar 26, 2023
bd4ec27
change version number
jipx Mar 27, 2023
d324098
change version
jipx Mar 27, 2023
286375f
version number
jipx Mar 27, 2023
4e94e83
version change
jipx Mar 27, 2023
8e36720
change verions number
jipx Mar 27, 2023
a2e3942
version changes
jipx Mar 27, 2023
bd44467
version number updated
jipx Mar 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,30 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
steps:
# Step 1
- name: Checkout to repo
uses: actions/checkout@v2

# Step 2
# Step 2
- name: Set AWS credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-session-token: ${{secrets.AWS_SESSION_TOKEN}}
aws-region: us-east-1

# Step 2
# - name: Set AWS credentials
# uses: aws-actions/configure-aws-credentials@v2
# with:
# role-to-assume: arn:aws:iam::530095765619:role/LabRole
# aws-region: us-east-1

# Step 3
- name: Create CodeDeploy Deployment
Expand All @@ -26,4 +38,4 @@ jobs:
--application-name nodejs-express-app \
--deployment-group-name nodejs-express-app-cd1 \
--deployment-config-name CodeDeployDefault.OneAtATime \
--github-location repository=${{ github.repository }},commitId=${{ github.sha }}
--github-location repository=${{ github.repository }},commitId=${{ github.sha }}
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ How to set ci/cd for nodejs app with aws codeDeploy and aws codePipeline
## Installation instructions

### 1. Launch amazon linux server in aws
Amazon Linux 2 (ARM, x86)
<a href ="https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent.html" target="_blank"> Supported Amazon EC2 AMI operating systems </a>

### 2. ssh to linux to install packages

Expand Down Expand Up @@ -58,7 +60,8 @@ nvm --version
#### 3.4 Install node

```sh
nvm install --lts # Latest stable node js server version
nvm install --lts # Latest stable node js server version 18.15.0, which is not well-supported, install a version which is active
nvm install 16.0.0
```

#### 3.5 Check nodejs installed
Expand All @@ -79,6 +82,7 @@ cd /home/ec2-user

```sh
git clone https://github.com/saasscaleup/nodejs-aws-codedeploy-pipeline.git
git clone https://github.com/jipx/nodejs-aws-codedeploy-pipeline.git
```

### 5. Run node app.js (Make sure everything working)
Expand Down Expand Up @@ -115,16 +119,19 @@ sudo ln -s "$(which pm2)" /sbin/pm2
### 8 Starting the app as sudo (Run nodejs in background and when server restart)
```sh
sudo pm2 start app.js --name=nodejs-express-app
pm2 start app.js --name=nodejs-express-app
```
```sh
sudo pm2 save # saves the running processes
# if not saved, pm2 will forget
# the running apps on next boot
pm2 save
```

#### 8.1 IMPORTANT: If you want pm2 to start on system boot
```sh
sudo pm2 startup # starts pm2 on computer boot
pm2 startup
```

### 9. Install aws code deploy agent
Expand All @@ -145,6 +152,10 @@ sudo ./install auto
```sh
sudo service codedeploy-agent start
```
```sh
sudo service codedeploy-agent status #check the service status
```
<a href="https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-verify.html#codedeploy-agent-operations-verify-linux"> verify the status</a>

### 10. Continue in AWS console...

Expand Down
34 changes: 20 additions & 14 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
const express = require('express');
const express = require("express");
const app = express();
const hostname = '127.0.0.1'; // Your server ip address
const hostname = "127.0.0.1"; // Your server ip address
const port = 3000;

const version = '3,000,000';
const version = "3.28.1.12.3334";

app.get('/', (req, res) => {
// set response content
res.send(`<html>
app.get("/", (req, res) => {
// set response content
res.send(`<html>
<body>
<h1 style="color:blue;text-align: center;margin-top: 100px;"> [Version ${version}]: THis is AMAZING!!! Like & Subscribe!</h1>
<div style="position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%)">
<img src="https://picsum.photos/400/400?random=1">
<h1 style="color:blue;text-align: center;margin-top: 100px;"> [Version ${version}]<br/> Good Night,Mr.jipx @library,THis is AMAZING!!! EC2 needs to have a profile to do the tasks</h1>
<div style="margin: auto;
width: 60%;
border: 3px solid #73AD21;
padding: 10px;">
<img src="https://picsum.photos/200/300?random=1" width=100% height=100%;>
</div>
</body>
</html>`);

console.log(`[Version ${version}]: New request => http://${hostname}:${port}`+req.url);

})
console.log(
`[Version ${version}]: New request => http://${hostname}:${port}` + req.url
);
});

app.listen(port, () => {
console.log(`[Version ${version}]: Server running at http://${hostname}:${port}/`);
})
console.log(
`[Version ${version}]: Server running at http://${hostname}:${port}/`
);
});
5 changes: 5 additions & 0 deletions userData
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
yum install -y aws-cli
cd /home/ec2-user/
aws s3 cp 's3://aws-codedeploy-us-east-1/latest/codedeploy-agent.noarch.rpm' . --region us-east-1
yum -y install codedeploy-agent.noarch.rpm