Similar to connecting to the app server instance, we connect through Session manager.

Switch to ec2-user.

Check the connection by pinging the ip of the Google DNS server → connected to the internet through IGW.

Download NPM to the instance:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bashsource ~/.bashrc to reload the bash shell configuration file to apply the npm just downloaded

nvm install 16 then run nvm use 16 to download and use Node.js version 16

To copy code from the library-app-fe folder from the S3 bucket we run the following commands:
cd to go to the user’s home directoryaws s3 cp s3://demowebapp-workshop-01/library-app-fe/ web-tier --recursive to copy all files from the library-app-fe folder and its sub-folders to the web-tier folder on the instance (if the web-tier folder does not exist, the instance will automatically create a new folder)

Download the dependencies:
cd web-tier to access the folderls -ltr to list the files and sub-folders of web-tier

npm install to download the necessary libraries or dependencies

npm run build to build the source code

sudo amazon-linux-extras install nginx1 -y to download nginx (nginx acts as a web server to help the app run on port 80, as well as help direct API calls to the internal load balancer)Config Nginx:
cd /etc/nginxls
sudo rm nginx.confsudo aws s3 cp s3://demowebapp-workshop-01/nginx.conf . to copy the file from the bucket to the nginx folder

sudo service nginx restart to restart Nginxchmod -R 755 /home/ec2-user to grant Nginx access to all filessudo chkconfig nginx on to run the Nginx service automatically every time the instance restarts