DEV Community

Doctorx
Doctorx

Posted on

How to update Elasticsearch Version on AWS

In the AWS Elasticsearch documentation part of CloudFormation nothing writes about how to update the Elasticsearch version. First glance it is simple. Only change version number ElasticsearchVersion.

If you update ElasticsearchVersion in the Elasticsearch template, You would catch exception AWS::Elasticsearch::Domain UPDATE_FAILED CloudFormation cannot update a stack when a custom-named resource requires replacing

How to fix it. You need to add new section UpdatePolicy to your CloudFormation template like this:

  ElasticsearchDomain:
    Type: "AWS::Elasticsearch::Domain"
    Properties:
      ElasticsearchVersion: 7.4 #New version for example 7.1 -> 7.4
    UpdatePolicy:
      EnableVersionUpgrade: true

Other way. You can use AWS API call

curl --location --request POST 'https://es.us-east-1.amazonaws.com/2015-01-01/es/upgradeDomain' \
--data-raw '{
  "DomainName": "test-es",
  "TargetVersion": "7.4",
  "PerformCheckOnly": true # If `true` AWS run only check-update
}'

I use the Postman with AWS Signature. Take AccessKey, SecretKey and Session Token from aws sts assume-role or aws sts get-session-token.

Documentation links

Top comments (0)