Member-only story
Deploying an AWS Elasticsearch Cluster with Serverless Framework
Deploying and connecting to an AWS Elasticsearch cluster from AWS Lambda using the Serverless Framework
In this article, I’ll demonstrate one approach for deploying an Elasticsearch domain to AWS using the Serverless Framework tooling without using any plugins. Using CloudFormation syntax, we’ll create the Elasticsearch cluster and then show how to make authorized requests to it using AWS Signature 4 signed requests. The article assumes familiarity with the Serverless Framework tooling and configuration (serverless.yml) and Elasticsearch, plus awareness of CloudFormation. In other words, you're here because you're using Serverless, and want to add Elasticsearch to your backend. Example Lambda handler code will be in JavaScript, but the Serverless configuration will work for any supported runtime.
Why not use a plugin? Yes, there are some Elasticsearch-related Serverless plugin. However, I find that most Serverless plugins are not well maintained and are often of dubious quality. Plugins can have access to your AWS credentials at deployment time, which, while often necessary for the plugin’s functionality, is kind of scary. Basically, I don’t trust most of them with access to my AWS account — and, as this article demonstrates, in most cases…
