cho.sh
Migrating Node.js apps from AWS EB to Heroku

Migrating Node.js apps from AWS EB to Heroku

Warning

Over a year old. May be outdated

Danger

I wrote this when I had little experience with Node.js. This is not an advisable way. It's simply where my journey started.

I'd used AWS Elastic Beanstalk for a while and figured Heroku had several advantages over AWS, so I moved KMLA Forms to Heroku. KMLA Forms simplifies writing the necessary official documents at my school, .

A few advantages I found.

  1. Money. AWS charges once you pass the free tier. Since some of the students in my school used my web app, I got some traffic, and AWS started asking me for about ~$10/month. As far as I know, Heroku has no free tier traffic limit.
  2. Native HTTPS support. Every dyno app can use Heroku's domain, so HTTPS just works. AWS EB doesn't give you that. You have to set up your domain and an HTTPS certificate for each one. Not valid for casual developers.

I had to make only minimal changes to app.js and package.json.

AWS Version

js
// ...

http.createServer(app).listen(8081, "0.0.0.0");

console.log("Server up and running at http://0.0.0.0:8081");

Heroku Version

js
// ...

const port = process.env.PORT || 8000;

// ...

app.listen(port, () => {
  console.log("App is running on port " + port);
});

I also added "start": "node app.js" to package.json. Code is on GitHub, and the app is live here.

Backlinks1