I am trying to switch a resource from aws_elasticsearch_domain to aws_opensearch_domain. Currently I am using aws_elasticsearch_domain/OpenSearch like this:
resource "aws_elasticsearch_domain" "my-search-service" {
domain_name = "my-search-${var.environment}"
elasticsearch_version = "OpenSearch_1.1"
...
cluster_config {
instance_type = "m5.large.elasticsearch"
...
I renamed the resource from aws_elasticsearch_domain to aws_openearch_domain - the name of this resource stayed the same. Then I followed the guide " Elasticsearch vs. OpenSearch" and I did:
- renamed
elasticsearch_version
toengine_version
- renamed instancy_typ suffix from
elasticsearch
tosearch
- didn’t have to change the roles
- I didn’t change the version, it stayed OpenSearch_1.1
The new version:
resource "aws_opensearch_domain" "my-search-service" {
domain_name = "my-search-${var.environment}"
engine_version = "OpenSearch_1.1"
....
cluster_config {
instance_type = "m5.large.search"
...
So the Terraform plan for such a change is it will:
Plan: 1 to add, 1 to change, 1 to destroy.
aws_elasticsearch_domain.my-search-service will be destroyed
aws_opensearch_domain.my-search-service will be created
So it didn’t detect that this is a replacement. Is it possible to switch in a non-destructive way? I would like to replace the cluster and its data, not create a new one from scratch