Terraform AWS elastic search version upgrade to Opensearch 1.0

I am trying to upgrade the domain from elastic search 7.10 to OpenSearch 1.0
It’s pretty straight forward to update via web app, just like how its shown below but how do we do this via terraform?

Currently, this is what I have in my terraform main.tf file:

resource “aws_elasticsearch_domain” “esD” {
count = 1
domain_name = “elastic_search”
elasticsearch_version = "7.10"

How do I upgrade my elastic search version to Open search 1.0 via Terraform? I am not able to find out any documentation in regards to this, is this something thats being worked on or Am I missing something? Any suggestion or help is much appreciated.

Changing the version to this worked.
elasticsearch_version = "OS_1.0"

Please do yourself a favour and use “OpenSearch_1.0” and not “OS_1.0”. It is translated properly but you will run into mismatches on consecutive runs causing resource to be destroyed.

Alright will try doing that.

Hi @tyburczyk and @Mohankumarmb91,

This is what I see when I execute terraform plan (quite scary)

resource "aws_elasticsearch_domain" "default" {
        ~ elasticsearch_version = "7.9" -> "OS_1.1" # forces replacement

Can anyone confirm that terraform apply performs an upgrade, and won’t delete and re-create the whole cluster?

Using short version name will cause resource recreation. Please use full names “OpenSearch_1.1”. (At least my domain was destroyed and recreated :frowning: )

Hi Hajdukd, Could you point me to any documents or detail regards to this “Short Name will trigger recreate”? Appreciated.

If use “OS_1.1” it will destroy the existing resource and recreate a new one, below is the output, shows it will destroy, add new and change the endpoint if applied.

# aws_elasticsearch_domain.elasticsearch must be replaced
-/+ resource "aws_elasticsearch_domain" "elasticsearch" {
    ~ advanced_options      = {
        - "override_main_response_version"         = "false"
        - "rest.action.multi.allow_explicit_index" = "true"
      } -> (known after apply)
    ~ arn                   = "existing-omitted" -> (known after apply)
    ~ elasticsearch_version = "7.10" -> "OS_1.1" # forces replacement
    ~ endpoint              = "omitted" -> (known after apply)
    ~ kibana_endpoint       = "omitted" -> (known after apply)

Plan: 1 to add, 3 to change, 1 to destroy.

While if you use “OpenSearch_1.1” it upgrade the elasticsearch version

# aws_elasticsearch_domain.elasticsearch will be updated in-place
  ~ resource "aws_elasticsearch_domain" "elasticsearch" {
      ~ elasticsearch_version = "7.10" -> "OpenSearch_1.1"
Plan: 0 to add, 3 to change, 0 to destroy.

Its recommended to use “OpenSearch_1.1” to avoid recreation of new resource.

1 Like