March 26, 2019
This will talk through the installation and possible pitfalls when deploying node.js applications on AWS Elastic Beanstalk service. While the documentation found on the AWS site is good it skips over some basics to get an application running. The application example is express app, that renders the current Billboard Top 100. Find the code here at Github.
The AWS CLI will let you configure your security credentials to allow access to your AWS account. The EB CLI is a far better tool for deployment on AWS Elastic Beanstalk itself, otherwise you are left uploading zip
files with your source code. Since the installation of both these packages is covered well on AWS Docs it is best to simply follow those.
The follow are the commands you will need to deploy your node application to AWS Elastic Beanstalk. I assume that you have successfully configured your AWS CLI by running aws configure
. Note: AWS Elastic Beanstalk will always deploy your latest git commit.
git init
and git add .
and git commit -m "hello aws eb"
your files."start": "node app"
in package.json
8081
to connect so be sure to define your ports as const port = process.env.PORT || 8081;
in your application.Run eb init
to create your application.
.elasticbeanstalk
directory with a config.yml
add it to your .gitignore
Run eb create
to create an environment for your app.
Use CodeCommit
since this is AWS Private Git repos. This step takes ~5 minutes.eb deploy
eb status
eb open
eb console
which will take you directly to Elastic Beanstalk console page. eb logs
.npmrc
file and add unsafe-perm=true
this is especially common for any dependecy that needs to compile from source and runs node-gyp
process.Modify software
Written by Farhad Agzamov who lives and works in London building things. You can follow him on Twitter and check out his github here