AWS Elastic Beanstalk is a cloud service provided by AWS using which you can quickly build and maintain apps in the AWS Cloud without needing to understand the infrastructure required to run those applications. It lessens the complexity of management without limiting choice or control. You only need to upload the application code and, Elastic Beanstalk will take care of the capacity provisioning, load balancing, scaling, and application health monitoring information automatically.
Applications created in Go, Java,.NET, Node.js, PHP, Python, and Ruby are supported by Elastic Beanstalk. Elastic Beanstalk creates the chosen supported platform version and sets up one or more AWS resources, like Amazon EC2 instances, to run your application when you deploy it.
In this blog, we will deploy a Node.js application using Elastic Beanstalk through the command line.
Prerequisites:
- A host machine with aws cli installed.
- The host is configured with IAM user profile with AWS Elastic Beanstalk administrator access policy attached to it.

Step1: Install EB CLI
- Run the following command to install the ebcli.
pip install awsebcli --upgrade --user
- Open the shell profile script in the user directory and add the path to the executable file to your path variable.
sudo vi ~/.bash_profile
export PATH=~/.local/bin:$PATH
- Verify if ebcli is installed with the following command.
eb --version
Step2: Create Beanstalk environment
- First, go to your project directory and initialize git.

- Use the following command to initialize git.
git init

- Create a .gitignore file and add the following in it.
node_modules/
.gitignore
.elasticbeanstalk/
- Next, create a repository with the following command.
eb init --platform node.js --region us-east-2
- Create a file ‘Procfile’ and copy the following in it.
vi Procfile
web: npm start
- Commit the files using git.
git add . git commit -m "first deploy"
- Create the environment using the following command.
eb create
- Enter environment name and DNS prefix and select type of load balancer.



- To check the status of the environment use the following command.
eb status

- Copy the CNAME and use your browser to access the application.

Please contact our DevOps engineer to discuss cloud infrastructure issues.
