In this post, we will make use of NodeJS and Docker to provide and API which interfaces with an Elasticsearch instance in AWS.

Assuming you already have an AWS account, and aws-cli set up.

Process

Write the NodeJS app locally

Wrap it a docker image and deploy this image to a registry (we will use docker hub here)

Use AWS ECS (EC2 Container Service) to deploy and scale your app in the cloud.

Write the NodeJS app locally

If you have your crendentials in ~/.aws/credentials, the connection to your Elasticsearch instance will be picked up
automatically. No need to worry about that.

We’re using here Jetbrain’s Webstorm and a new Express project comes with several dependencies, some of which we don’t
need. Still, let’s keep them for simplicity and add some others related to the project, in particular elasticsearch,
http-aws-es and aws-sdk.

Run your container locally

aws cli gets credentials in a specific order
and so far, we’ve used the ones stored in the credentials file. This is fine because your local machine is where the
cli is installed. But the docker container has no idea about this file. We could share it or copy it with the container.
Another option, more production-friendly is to pass credentials as environment variables. It’s described below.