<aside> 🌱 The following is a tutorial for deploying and hosting a Next.js web app on AWS, using their Elastic Beanstalk service. Elastic Beanstalk (EB) is a service used to deploy, manage, and scale web applications and services.

</aside>

Step 0: Satisfy the Prerequisites

  1. Have a Next.js Web App ready that you want to deploy: https://nextjs.org/docs If you don't have a Next.js ready to deploy, feel free to follow along with this tutorial by using a simple application. To get started, just run npx create-next-app {YOUR_APP_NAME} and you should be good to go!
  2. Get an AWS account, if you do not have one already: https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/ This step may change, as you may be able to use our Hack4Impact AWS account.
  3. Install the Elastic Beanstalk CLI for AWS: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-osx.html If you're on Mac, this will involve running brew update then brew install awsebcli. Afterwards, you can check your installation by running eb --version. If this doesn't work, or if you're using Windows or Linux, please refer to the link above.
  4. Configure the Elastic Beanstalk CLI with an IAM user with the proper permissions: https://aws.amazon.com/getting-started/hands-on/set-up-command-line-elastic-beanstalk/ After creating your IAM user, make sure to save the credentials to a CSV file for safekeeping! You will need the Access key ID and Secret access key later on in this tutorial.

Step 1: Create the Elastic Beanstalk application

Within your project's root directory, type eb init and hit enter. This will create a new Elastic Beanstalk application and begin the set-up process for the application.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/bf9e242b-98b4-4177-b7dc-24468ab74365/Untitled.png

You will then be prompted to select a region for your application. Choose the region that is closest to you. (I chose us-west-2)

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/577964af-1bd2-454b-b7d6-4e48fad5ebee/Untitled.png

Next, you will be asked to provide your IAM user credentials. Use the Access key ID and the Secret access key values that you generated. If this doesn't make sense to you, please see Task #4 of the prerequisites.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/3a1a8b0f-f036-4318-8a5d-f3ce449f8b51/Untitled.png

At this point, Elastic Beanstalk should automatically detect that you're using Node.js. Select the version of Node that you're using. You can determine this by running node --version in a separate terminal.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/362f53d8-2390-4595-b9e0-9e91a6b106e0/Untitled.png

It will then ask if you'd like to use CodeCommit (Amazon's version of GitHub). Say no (unless of course, you actually use CodeCommit).

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/3f702a46-8932-4fe7-a5d4-1f6bfb1afa5b/Untitled.png

It will then ask if you'd like to set-up SSH for your instances. If you'd like to do this for your project, enter y. We won't need to SSH for the purposes of this tutorial, so feel free to type n.