Setting up AWS Elasticsearch with Serverless and CloudFormation

April 10, 2019 • 1 min read • serverless

A very short post

Here is how you can setup an ES cluster using the Serverless framework and CloudFormation:

        service: my-service

provider:
  name: aws
  runtime: nodejs8.10
  stage: ${self:custom.stage}
  region: ${self:custom.region}

resources:
  Resources:
    ElasticSearch:
      Type: AWS::Elasticsearch::Domain
      Condition: CreateElasticSearch
      Properties:
        DomainName: myDomainName
        EBSOptions:
          EBSEnabled: true
          VolumeType: gp2
          VolumeSize: 20
        ElasticsearchClusterConfig:
          InstanceType: m3.medium.elasticsearch
          InstanceCount: 1
          DedicatedMasterEnabled: false
          ZoneAwarenessEnabled: false
        ElasticsearchVersion: 6.3

  Outputs:
    # Export ElasticSearch host url
    ElasticSearchHost:
      Description: 'ElasticSearch host url'
      Condition: CreateElasticSearch
      Value:
        Fn::GetAtt:
          - ElasticSearch
          - DomainEndpoint
      Export:
        # This name will be used to import a host url
        Name: elasticSearchHost

I hope you find this useful!

For more details and options you can visit the AWS documentation


comments powered by Disqus

Do you want to contact me? → Click!