Deploying a simple Node JS application to AWS ElasticBeanstalk using AWS CloudFormation

This article will show you how to deploy a simple Node JS application to ElasticBeanstalk using CloudFormation. Most of the process is done using the template and CLI. You will need to have AWS command line installed and IAM credentials configured for your laptop.

First, you will need to login to the AWS console and create an S3 bucket to store your template.

Then, you will need to create an SSH key pair for the EC2 instance. For that, you will need to go to the EC2 service, and then go to the Key Pairs section under the NETWORK & SECURITY section on the left main menu. Then create a Key Pair choosing “pem” option. You will need to use the key name later.

Then you need to create a file called template.yml file with the following content.

Then you will need to run the following command replacing the <BucketName> with your Bucket’s name with the same folder as the template.yml.

Then you need to run the following command replacing the <KeyName> with the name of the SSH Key Pair you created in the beginning. For the <StackName>, you can put the name you want for your stack.

That’s it. When the command was run successfully, you will see the CloudFormation template was created successfully in the console. You will also see an ElasticBeanstalk environment created for you.

Software Developer based in the UK, used to work in Singapore, but originally from Myanmar.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store