Running a NextJS application in AWS EC2 with AWS CodePipeline involves several steps:
- Create an EC2 instance:
First, you must create an EC2 instance in the AWS Management Console. Choose the Amazon Linux 2 AMI and select an instance type based on your application’s requirements.
In the userdata section, put this script to create necessary packages at run time
!#/bin/bash
sudo yum update -y
sudo amazon-linux-extras install nginx1 -y
# Start Nginx service
sudo systemctl start nginx
sudo systemctl enable nginx
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum-config-manager --enable epel
sudo yum install certbot python2-certbot-nginx -y