DEV Community

Cover image for How to deploy a nextjs app to AWS EC2 with Github action

How to deploy a nextjs app to AWS EC2 with Github action

Phan Công Thắng on August 22, 2021

I want to deploy an application to AWS. In the first time, I was overwhelmed with the architecture of AWS and couldn't find tutorials for people wi...
Collapse
 
ptejada profile image
Pablo Tejada • Edited

I like the guide with the screenshots but for a Next.js app Amplify is so much more practical and cost effective. You literally just have to connect your repo and you are good to go.

Collapse
 
thangphan37 profile image
Phan Công Thắng

Totally agree with you. It's so easy to deploy a next app with Amplify.😅

Collapse
 
alejomartinez8 profile image
Alejandro Martinez

I have had that question, what's the difference to deploy on EC2 and Amplify?, in my job they have it on EC2, but I found many docs with Amplify. Thanks. Greate Article!

Thread Thread
 
thangphan37 profile image
Phan Công Thắng

I think You can secure, compute your app with EC2. But using Amplify you can't do that. Amplify can be useful in case You want to deploy apps quickly.

Thread Thread
 
ptejada profile image
Pablo Tejada

What do you mean by secure?

Thread Thread
 
thangphan37 profile image
Phan Công Thắng

I think You can restrict what IP can access to the resources that you have deployed to EC2!

Thread Thread
 
ptejada profile image
Pablo Tejada

I mean EC2 is not serverless for sure. You can also create EC2 snapshots.

I am really not sure the point you are trying to make here. If you want whitelist access to your serverless service you can do that as well. It will definitely not look like whitelisting access to an EC2, and they should not look alike because they are two different things.

Collapse
 
alejomartinez8 profile image
Alejandro Martinez

I have an error on build step, name unknown: The repository with name 'demo-deploy' does not exist in the registry with id '***', I don't know what I missing.

Collapse
 
thangphan37 profile image
Phan Công Thắng • Edited

Hmm, Did this error come from github-action 's log or ECS's log ?

Collapse
 
alejomartinez8 profile image
Alejandro Martinez

From github-action's log, my repo is here github.com/alejomartinez8/deploy-demo maybe I don't understand the ECR configuration

This code is from my aws? uses: aws-actions/configure-aws-credentials@13d241b293754004c80624b5567555c4a39ffbe3 I saw in this repo github.com/aws-actions/amazon-ecr-... they just use uses: aws-actions/amazon-ecr-login@v1 there are any difference?

Thread Thread
 
thangphan37 profile image
Phan Công Thắng

Did you create a repo in ECR envinronment?

I think the matter isn't uses's config, it's only the version of amazon-ecr-login that you would like to set up.

Collapse
 
karanpratapsingh profile image
Karan Pratap Singh

Great article!