如何使用 CloudFormation 为 Amazon OpenSearch 设置兼容模式?

How can I set compatibility mode for Amazon OpenSearch using CloudFormation?

由于 AWS 已将 ElasticSearch 替换为 OpenSearch,一些客户在连接到 OpenSearch 服务时遇到问题。

为避免这种情况,我们可以在集群创建期间启用兼容模式。

Certain Elasticsearch OSS clients, such as Logstash, check the cluster version before connecting. Compatibility mode sets OpenSearch to report its version as 7.10 so that these clients continue to work with the service.

我正在尝试使用 CloudFormation 创建集群,使用 AWS::OpenSearchService::Domain 而不是 AWS::Elasticsearch::Domain 但我看不到启用兼容模式的方法。

AWS::OpenSearchService::Domain CloudFormation resource has a property called AdvancedOptions.

根据documentation,您应该将override_main_response_version传递给高级选项以启用兼容模式。

示例:

Resources:
  OpenSearchServiceDomain:
    Type: AWS::OpenSearchService::Domain
    Properties:
      DomainName: 'test'
      EngineVersion: 'OpenSearch_1.0'
      AdvancedOptions:
        override_main_response_version: true

您可以在高级部分选项卡 AdvancedOptions 中添加它。

示例:

资源: 打开搜索服务域: 类型:AWS::OpenSearchService::Domain 特性: 高级选项: override_main_response_version: 真

要在 terraform 中执行此操作,请使用配置

resource "aws_elasticsearch_domain" "search" {
  domain_name = "search"

  advanced_options = {
    "override_main_response_version" = "true"
  }
}

可以在此处找到文档 https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticsearch_domain