Skip to content

Commit

Permalink
Update chapter 2 bash code
Browse files Browse the repository at this point in the history
  • Loading branch information
brikis98 committed Jun 20, 2024
1 parent 5e31ec4 commit 1fd5f5d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ch2/bash/deploy-ec2-instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

export AWS_DEFAULT_REGION="us-east-2"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
user_data=$(cat "$SCRIPT_DIR/../../ch/ec2-user-data-script/user-data.sh")
user_data=$(cat "$SCRIPT_DIR/user-data.sh")

security_group_id=$(aws ec2 create-security-group \
--group-name "sample-app" \
Expand Down
22 changes: 22 additions & 0 deletions ch2/bash/user-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e

curl -fsSL https://rpm.nodesource.com/setup_21.x | bash -
yum install -y nodejs

tee app.js > /dev/null << "EOF"
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello, World!\n');
});
const port = 80;
server.listen(port,() => {
console.log(`Listening on port ${port}`);
});
EOF

nohup node app.js &

0 comments on commit 1fd5f5d

Please sign in to comment.