How to Run a NextJS Application in AWS EC2 with AWS CodePipeline

Running a NextJS application in AWS EC2 with AWS CodePipeline involves several steps:

  1. 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

Atiqur Rahman

I am MD. Atiqur Rahman graduated from BUET and is an AWS-certified solutions architect. I have successfully achieved 6 certifications from AWS including Cloud Practitioner, Solutions Architect, SysOps Administrator, and Developer Associate. I have more than 8 years of working experience as a DevOps engineer designing complex SAAS applications.

Leave a Reply