Amazon Elasticsearch Serviceチュートリアル

Amazon Elasticsearch Service のdeployやデータ投入、検索リクエストを試すべく、以下資料を参考に進めていきます。 今回はAWS CDKでElasticsearch Serviceドメインクラスタ)を作成する方法で行っていきます。

参考資料

インストール

まず、aws-cdkをインストールします

$ npm i -g aws-cdk
/usr/local/bin/cdk -> /usr/local/lib/node_modules/aws-cdk/bin/cdk
+ aws-cdk@1.70.0
added 189 packages from 186 contributors in 4.708s

バージョン情報

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.7
BuildVersion:   19H2
$ cdk version
1.70.0 (build c145314)

CDKプロジェクト作成

CDKプロジェクトを作成します。
今回はPythonで実装するので、 --language pythonオプションを指定します。

$ mkdir hello-cdk-es
$ cd hello-cdk-es
$ cdk init --language python
Applying project template app for python

# Welcome to your CDK Python project!

This is a blank project for Python development with CDK.

The `cdk.json` file tells the CDK Toolkit how to execute your app.

This project is set up like a standard Python project.  The initialization
process also creates a virtualenv within this project, stored under the .env
directory.  To create the virtualenv it assumes that there is a `python3`
(or `python` for Windows) executable in your path with access to the `venv`
package. If for any reason the automatic creation of the virtualenv fails,
you can create the virtualenv manually.

To manually create a virtualenv on MacOS and Linux:

```
$ python3 -m venv .env
```

After the init process completes and the virtualenv is created, you can use the following
step to activate your virtualenv.

```
$ source .env/bin/activate
```

If you are a Windows platform, you would activate the virtualenv like this:

```
% .env\Scripts\activate.bat
```

Once the virtualenv is activated, you can install the required dependencies.

```
$ pip install -r requirements.txt
```

At this point you can now synthesize the CloudFormation template for this code.

```
$ cdk synth
```

To add additional dependencies, for example other CDK libraries, just add
them to your `setup.py` file and rerun the `pip install -r requirements.txt`
command.

## Useful commands

 * `cdk ls`          list all stacks in the app
 * `cdk synth`       emits the synthesized CloudFormation template
 * `cdk deploy`      deploy this stack to your default AWS account/region
 * `cdk diff`        compare deployed stack with current state
 * `cdk docs`        open CDK documentation

Enjoy!

Initializing a new git repository...
Please run 'python3 -m venv .env'!
Executing Creating virtualenv...
✅ All done!

生成ファイル確認

$ tree -L 1
.
├── README.md
├── app.py
├── cdk.json
├── hello_cdk_es
├── requirements.txt
├── setup.py
└── source.bat

1 directory, 6 files

必要なパッケージのインストール

$ python3 -m venv .env
$ source ./.env/bin/activate
$ pip list
Package    Version
---------- -------
pip        20.2.4
setuptools 49.2.1
$ pip install -r requirements.txt
:
Collecting aws-cdk.core==1.70.0
  Downloading aws_cdk.core-1.70.0-py3-none-any.whl (780 kB)
     |████████████████████████████████| 780 kB 3.3 MB/s
Collecting constructs<4.0.0,>=3.0.4
  Downloading constructs-3.1.3-py3-none-any.whl (57 kB)
     |████████████████████████████████| 57 kB 8.8 MB/s
Collecting jsii<2.0.0,>=1.13.0
  Downloading jsii-1.13.0-py3-none-any.whl (266 kB)
     |████████████████████████████████| 266 kB 11.1 MB/s
Collecting aws-cdk.region-info==1.70.0
  Downloading aws_cdk.region_info-1.70.0-py3-none-any.whl (56 kB)
     |████████████████████████████████| 56 kB 6.2 MB/s
Collecting publication>=0.0.3
  Downloading publication-0.0.3-py2.py3-none-any.whl (7.7 kB)
Collecting aws-cdk.cx-api==1.70.0
  Downloading aws_cdk.cx_api-1.70.0-py3-none-any.whl (99 kB)
     |████████████████████████████████| 99 kB 12.7 MB/s
Collecting aws-cdk.cloud-assembly-schema==1.70.0
  Downloading aws_cdk.cloud_assembly_schema-1.70.0-py3-none-any.whl (106 kB)
     |████████████████████████████████| 106 kB 12.6 MB/s
Collecting attrs~=20.1
  Downloading attrs-20.2.0-py2.py3-none-any.whl (48 kB)
     |████████████████████████████████| 48 kB 9.2 MB/s
Collecting typing-extensions~=3.7
  Downloading typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Collecting cattrs~=1.0
  Downloading cattrs-1.0.0-py2.py3-none-any.whl (14 kB)
Collecting python-dateutil
  Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting six>=1.5
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: attrs, typing-extensions, cattrs, six, python-dateutil, jsii, publication, constructs, aws-cdk.region-info, aws-cdk.cloud-assembly-schema, aws-cdk.cx-api, aws-cdk.core, hello-cdk-es
  Running setup.py develop for hello-cdk-es
Successfully installed attrs-20.2.0 aws-cdk.cloud-assembly-schema-1.70.0 aws-cdk.core-1.70.0 aws-cdk.cx-api-1.70.0 aws-cdk.region-info-1.70.0 cattrs-1.0.0 constructs-3.1.3 hello-cdk-es jsii-1.13.0 publication-0.0.3 python-dateutil-2.8.1 six-1.15.0 typing-extensions-3.7.4.3

aws-cdk.aws-elasticsearchのインストール

$ pip install aws-cdk.aws-elasticsearch
Collecting aws-cdk.aws-elasticsearch
  Downloading aws_cdk.aws_elasticsearch-1.70.0-py3-none-any.whl (103 kB)
     |████████████████████████████████| 103 kB 2.0 MB/s
Collecting aws-cdk.aws-cloudwatch==1.70.0
  Downloading aws_cdk.aws_cloudwatch-1.70.0-py3-none-any.whl (180 kB)
     |████████████████████████████████| 180 kB 6.2 MB/s
Requirement already satisfied: jsii<2.0.0,>=1.13.0 in ./.env/lib/python3.8/site-packages (from aws-cdk.aws-elasticsearch) (1.13.0)
Requirement already satisfied: constructs<4.0.0,>=3.0.4 in ./.env/lib/python3.8/site-packages (from aws-cdk.aws-elasticsearch) (3.1.3)
Requirement already satisfied: aws-cdk.core==1.70.0 in ./.env/lib/python3.8/site-packages (from aws-cdk.aws-elasticsearch) (1.70.0)
Collecting aws-cdk.aws-kms==1.70.0
  Downloading aws_cdk.aws_kms-1.70.0-py3-none-any.whl (57 kB)
     |████████████████████████████████| 57 kB 14.2 MB/s
Collecting aws-cdk.aws-logs==1.70.0
  Downloading aws_cdk.aws_logs-1.70.0-py3-none-any.whl (102 kB)
     |████████████████████████████████| 102 kB 7.6 MB/s
Requirement already satisfied: publication>=0.0.3 in ./.env/lib/python3.8/site-packages (from aws-cdk.aws-elasticsearch) (0.0.3)
Collecting aws-cdk.custom-resources==1.70.0
  Downloading aws_cdk.custom_resources-1.70.0-py3-none-any.whl (94 kB)
     |████████████████████████████████| 94 kB 5.7 MB/s
Collecting aws-cdk.aws-iam==1.70.0
  Downloading aws_cdk.aws_iam-1.70.0-py3-none-any.whl (223 kB)
     |████████████████████████████████| 223 kB 6.0 MB/s
Collecting aws-cdk.aws-secretsmanager==1.70.0
  Downloading aws_cdk.aws_secretsmanager-1.70.0-py3-none-any.whl (94 kB)
     |████████████████████████████████| 94 kB 7.0 MB/s
Collecting aws-cdk.aws-ec2==1.70.0
  Downloading aws_cdk.aws_ec2-1.70.0-py3-none-any.whl (818 kB)
     |████████████████████████████████| 818 kB 8.5 MB/s
Requirement already satisfied: python-dateutil in ./.env/lib/python3.8/site-packages (from jsii<2.0.0,>=1.13.0->aws-cdk.aws-elasticsearch) (2.8.1)
Requirement already satisfied: attrs~=20.1 in ./.env/lib/python3.8/site-packages (from jsii<2.0.0,>=1.13.0->aws-cdk.aws-elasticsearch) (20.2.0)
Requirement already satisfied: cattrs~=1.0 in ./.env/lib/python3.8/site-packages (from jsii<2.0.0,>=1.13.0->aws-cdk.aws-elasticsearch) (1.0.0)
Requirement already satisfied: typing-extensions~=3.7 in ./.env/lib/python3.8/site-packages (from jsii<2.0.0,>=1.13.0->aws-cdk.aws-elasticsearch) (3.7.4.3)
Requirement already satisfied: aws-cdk.cloud-assembly-schema==1.70.0 in ./.env/lib/python3.8/site-packages (from aws-cdk.core==1.70.0->aws-cdk.aws-elasticsearch) (1.70.0)
Requirement already satisfied: aws-cdk.cx-api==1.70.0 in ./.env/lib/python3.8/site-packages (from aws-cdk.core==1.70.0->aws-cdk.aws-elasticsearch) (1.70.0)
Requirement already satisfied: aws-cdk.region-info==1.70.0 in ./.env/lib/python3.8/site-packages (from aws-cdk.core==1.70.0->aws-cdk.aws-elasticsearch) (1.70.0)
Collecting aws-cdk.aws-s3-assets==1.70.0
  Downloading aws_cdk.aws_s3_assets-1.70.0-py3-none-any.whl (32 kB)
Collecting aws-cdk.aws-cloudformation==1.70.0
  Downloading aws_cdk.aws_cloudformation-1.70.0-py3-none-any.whl (59 kB)
     |████████████████████████████████| 59 kB 7.5 MB/s
Collecting aws-cdk.aws-lambda==1.70.0
  Downloading aws_cdk.aws_lambda-1.70.0-py3-none-any.whl (262 kB)
     |████████████████████████████████| 262 kB 9.0 MB/s
Collecting aws-cdk.aws-sns==1.70.0
  Downloading aws_cdk.aws_sns-1.70.0-py3-none-any.whl (68 kB)
     |████████████████████████████████| 68 kB 10.0 MB/s
Collecting aws-cdk.aws-sam==1.70.0
  Downloading aws_cdk.aws_sam-1.70.0-py3-none-any.whl (127 kB)
     |████████████████████████████████| 127 kB 14.7 MB/s
Collecting aws-cdk.aws-ssm==1.70.0
  Downloading aws_cdk.aws_ssm-1.70.0-py3-none-any.whl (117 kB)
     |████████████████████████████████| 117 kB 12.9 MB/s
Collecting aws-cdk.aws-s3==1.70.0
  Downloading aws_cdk.aws_s3-1.70.0-py3-none-any.whl (214 kB)
     |████████████████████████████████| 214 kB 13.4 MB/s
Collecting aws-cdk.assets==1.70.0
  Downloading aws_cdk.assets-1.70.0-py3-none-any.whl (16 kB)
Requirement already satisfied: six>=1.5 in ./.env/lib/python3.8/site-packages (from python-dateutil->jsii<2.0.0,>=1.13.0->aws-cdk.aws-elasticsearch) (1.15.0)
Collecting aws-cdk.aws-applicationautoscaling==1.70.0
  Downloading aws_cdk.aws_applicationautoscaling-1.70.0-py3-none-any.whl (99 kB)
     |████████████████████████████████| 99 kB 11.8 MB/s
Collecting aws-cdk.aws-events==1.70.0
  Downloading aws_cdk.aws_events-1.70.0-py3-none-any.whl (109 kB)
     |████████████████████████████████| 109 kB 11.9 MB/s
Collecting aws-cdk.aws-efs==1.70.0
  Downloading aws_cdk.aws_efs-1.70.0-py3-none-any.whl (63 kB)
     |████████████████████████████████| 63 kB 5.2 MB/s
Collecting aws-cdk.aws-sqs==1.70.0
  Downloading aws_cdk.aws_sqs-1.70.0-py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 9.3 MB/s
Collecting aws-cdk.aws-codeguruprofiler==1.70.0
  Downloading aws_cdk.aws_codeguruprofiler-1.70.0-py3-none-any.whl (31 kB)
Collecting aws-cdk.aws-autoscaling-common==1.70.0
  Downloading aws_cdk.aws_autoscaling_common-1.70.0-py3-none-any.whl (26 kB)
Installing collected packages: aws-cdk.aws-iam, aws-cdk.aws-cloudwatch, aws-cdk.aws-kms, aws-cdk.aws-events, aws-cdk.aws-s3, aws-cdk.assets, aws-cdk.aws-s3-assets, aws-cdk.aws-logs, aws-cdk.aws-autoscaling-common, aws-cdk.aws-applicationautoscaling, aws-cdk.aws-ssm, aws-cdk.aws-ec2, aws-cdk.aws-efs, aws-cdk.aws-sqs, aws-cdk.aws-codeguruprofiler, aws-cdk.aws-lambda, aws-cdk.aws-sns, aws-cdk.aws-cloudformation, aws-cdk.custom-resources, aws-cdk.aws-sam, aws-cdk.aws-secretsmanager, aws-cdk.aws-elasticsearch
Successfully installed aws-cdk.assets-1.70.0 aws-cdk.aws-applicationautoscaling-1.70.0 aws-cdk.aws-autoscaling-common-1.70.0 aws-cdk.aws-cloudformation-1.70.0 aws-cdk.aws-cloudwatch-1.70.0 aws-cdk.aws-codeguruprofiler-1.70.0 aws-cdk.aws-ec2-1.70.0 aws-cdk.aws-efs-1.70.0 aws-cdk.aws-elasticsearch-1.70.0 aws-cdk.aws-events-1.70.0 aws-cdk.aws-iam-1.70.0 aws-cdk.aws-kms-1.70.0 aws-cdk.aws-lambda-1.70.0 aws-cdk.aws-logs-1.70.0 aws-cdk.aws-s3-1.70.0 aws-cdk.aws-s3-assets-1.70.0 aws-cdk.aws-sam-1.70.0 aws-cdk.aws-secretsmanager-1.70.0 aws-cdk.aws-sns-1.70.0 aws-cdk.aws-sqs-1.70.0 aws-cdk.aws-ssm-1.70.0 aws-cdk.custom-resources-1.70.0

CDKデプロイ

$ cdk list
AwsEsStack

CDK初回デプロイ時、CloudFormationで利用するデプロイ用S3バケットの作成します。

$ cdk bootstrap
 ⏳  Bootstrapping environment aws://867065454662/us-east-1...
CDKToolkit: creating CloudFormation changeset...
[██████████████████████████████████████████████████████████] (3/3)



 ✅  Environment aws://867065454662/us-east-1 bootstrapped.

Amazon Elasticsearchの設定定義

以下のpythonスクリプトで定義。アクセスポリシーは今回はIP制限のみ

CDK定義

以下のように利用するelasticsearch versionを追加してみます。

 "es": {
      "version": "7.7"
    }

https://github.com/kenji-imi/hello_cdk_es/blob/master/cdk.json

CDKデプロイ

$ cdk deploy ## ドメイン作成

hello-cdk-es: deploying...
hello-cdk-es: creating CloudFormation changeset...
 0/3 | 16:17:35 | REVIEW_IN_PROGRESS   | AWS::CloudFormation::Stack | hello-cdk-es User Initiated
 0/3 | 16:17:40 | CREATE_IN_PROGRESS   | AWS::CloudFormation::Stack | hello-cdk-es User Initiated
 0/3 | 16:17:45 | CREATE_IN_PROGRESS   | AWS::Elasticsearch::Domain | HelloCdkEs
 0/3 | 16:17:45 | CREATE_IN_PROGRESS   | AWS::CDK::Metadata         | CDKMetadata/Default (CDKMetadata)
 1/3 | 16:17:47 | CREATE_IN_PROGRESS   | AWS::CDK::Metadata         | CDKMetadata/Default (CDKMetadata) Resource creation Initiated
 1/3 | 16:17:47 | CREATE_COMPLETE      | AWS::CDK::Metadata         | CDKMetadata/Default (CDKMetadata)
 1/3 | 16:17:48 | CREATE_IN_PROGRESS   | AWS::Elasticsearch::Domain | HelloCdkEs Resource creation Initiated
1/3 Currently in progress: hello-cdk-es, HelloCdkEs
 2/3 | 16:33:52 | CREATE_COMPLETE      | AWS::Elasticsearch::Domain | HelloCdkEs
 3/3 | 16:33:54 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | hello-cdk-es
Stack hello-cdk-es has completed updating

 ✅  hello-cdk-es

Stack ARN:
arn:aws:cloudformation:us-east-1:867065454662:stack/hello-cdk-es/7c6a6990-1824-11eb-8a28-12f8925a37c4

ドメイン作成確認

$ aws es list-domain-names
{
    "DomainNames": [
        {
            "DomainName": "hello-cdk-es"
        }
    ]
}
$ aws es list-domain-names
You must specify a region. You can also configure your region by running "aws configure".
$ curl -s https://checkip.amazonaws.com
103.5.140.182

設定

settings.json

{
  "settings": {
    "analysis": {
      "analyzer": {
        "index_analyzer": {
          "type": "custom",
          "tokenizer": "kuromoji_tokenizer",
          "mode": "search",
          "char_filter": ["icu_normalizer", "kuromoji_iteration_mark"],
          "filter": [
            "cjk_width",
            "kuromoji_baseform",
            "kuromoji_part_of_speech",
            "ja_stop",
            "lowercase",
            "kuromoji_number",
            "kuromoji_stemmer"
          ]
        }
      },
      "tokenizer": {
        "kuromoji_tokenizer": {
          "type": "kuromoji_tokenizer",
          "mode": "normal"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "company": {
        "type": "text",
        "analyzer": "index_analyzer"
      },
      "products": {
        "type": "text",
        "analyzer": "index_analyzer"
      }
    }
  }
}

設定用リクエス

$ curl -s -XPUT "search-hello-cdk-es-orziggze45iaxzd2wcaz2tdwze.us-east-1.es.amazonaws.com/test?pretty" -H "Content-type: application/json" -d @settings.json
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "test"
}

設定確認リクエス

$ curl -s -XGET "search-hello-cdk-es-orziggze45iaxzd2wcaz2tdwze.us-east-1.es.amazonaws.com/test/_mapping?pretty"
{
  "test": {
    "mappings": {
      "properties": {
        "company": {
          "type": "text",
          "analyzer": "index_analyzer"
        },
        "products": {
          "type": "text",
          "analyzer": "index_analyzer"
        }
      }
    }
  }
}

データ投入

データ投入は、bulk insertで行います。

data.json

{"index": {"_index": "test","_type": "_doc","_id": "1"}}
{"company": "SHARP", "products": "SHARP AQUOS 4T-C50BN1"}
{"index": {"_index": "test","_type": "_doc","_id": "2"}}
{"company": "Panasonic", "products": "Panasonic VIERA HZ2000"}
{"index": {"_index": "test","_type": "_doc","_id": "3"}}
{"company": "SONY", "products": "SONY BRAVIA KJ-65A8H"}

buku insertリクエス

$ curl -s -XPOST "search-hello-cdk-es-orziggze45iaxzd2wcaz2tdwze.us-east-1.es.amazonaws.com/_bulk?pretty" -H "Content-type: application/json" --data-binary @data.json
{
  "took": 41,
  "errors": false,
  "items": [
    {
      "index": {
        "_index": "test",
        "_type": "_doc",
        "_id": "1",
        "_version": 1,
        "result": "created",
        "_shards": {
          "total": 2,
          "successful": 1,
          "failed": 0
        },
        "_seq_no": 0,
        "_primary_term": 1,
        "status": 201
      }
    },
    {
      "index": {
        "_index": "test",
        "_type": "_doc",
        "_id": "2",
        "_version": 1,
        "result": "created",
        "_shards": {
          "total": 2,
          "successful": 1,
          "failed": 0
        },
        "_seq_no": 0,
        "_primary_term": 1,
        "status": 201
      }
    },
    {
      "index": {
        "_index": "test",
        "_type": "_doc",
        "_id": "3",
        "_version": 1,
        "result": "created",
        "_shards": {
          "total": 2,
          "successful": 1,
          "failed": 0
        },
        "_seq_no": 0,
        "_primary_term": 1,
        "status": 201
      }
    }
  ]
}

検索

query.json

{
  "query": { "match": { "products": "BRAVIA" } }
}

検索リクエス

$ curl -s -XGET "search-hello-cdk-es-orziggze45iaxzd2wcaz2tdwze.us-east-1.es.amazonaws.com/test/_search?pretty" -H "Content-type: application/json" -d @query.json
{
  "took": 308,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 0.2876821,
    "hits": [
      {
        "_index": "test",
        "_type": "_doc",
        "_id": "3",
        "_score": 0.2876821,
        "_source": {
          "company": "SONY",
          "products": "SONY BRAVIA KJ-65A8H"
        }
      }
    ]
  }
}

インデックス削除

検索が出来たことを確認したので、インデックスを削除します。
削除する前にインデックス存在チェックします。

インデックス存在確認用に以下リクエストを行います。

$ curl -s -XGET "search-hello-cdk-es-orziggze45iaxzd2wcaz2tdwze.us-east-1.es.amazonaws.com/test?pretty"
{
  "test" : {
    "aliases" : { },
    "mappings" : {
      "properties" : {
        "company" : {
          "type" : "text",
          "analyzer" : "index_analyzer"
        },
        "products" : {
          "type" : "text",
          "analyzer" : "index_analyzer"
        }
      }
    },
    "settings" : {
      "index" : {
        "number_of_shards" : "5",
        "provided_name" : "test",
        "creation_date" : "1603785392481",
        "analysis" : {
          "analyzer" : {
            "index_analyzer" : {
              "filter" : [ "cjk_width", "kuromoji_baseform", "kuromoji_part_of_speech", "ja_stop", "lowercase", "kuromoji_number", "kuromoji_stemmer" ],
              "mode" : "search",
              "char_filter" : [ "icu_normalizer", "kuromoji_iteration_mark" ],
              "type" : "custom",
              "tokenizer" : "kuromoji_tokenizer"
            }
          },
          "tokenizer" : {
            "kuromoji_tokenizer" : {
              "mode" : "normal",
              "type" : "kuromoji_tokenizer"
            }
          }
        },
        "number_of_replicas" : "1",
        "uuid" : "1e1cI4fMSfOl_KJziJ8VKQ",
        "version" : {
          "created" : "7070099"
        }
      }
    }
  }
}

削除リクエス

$ curl -XDELETE "search-hello-cdk-es-orziggze45iaxzd2wcaz2tdwze.us-east-1.es.amazonaws.com/test?pretty"
{
  "acknowledged" : true
}

再度インデックス存在確認用のリクエストを行うと、NotFoundエラーになり、削除されたことを確認。

$ curl -s -XGET "search-hello-cdk-es-orziggze45iaxzd2wcaz2tdwze.us-east-1.es.amazonaws.com/test?pretty"
{
  "error" : {
    "root_cause" : [
      {
        "type" : "index_not_found_exception",
        "reason" : "no such index [test]",
        "resource.type" : "index_or_alias",
        "resource.id" : "test",
        "index_uuid" : "_na_",
        "index" : "test"
      }
    ],
    "type" : "index_not_found_exception",
    "reason" : "no such index [test]",
    "resource.type" : "index_or_alias",
    "resource.id" : "test",
    "index_uuid" : "_na_",
    "index" : "test"
  },
  "status" : 404
}

Elasitcsearchドメイン削除

最後に、ドメインの削除を行います。

$ aws es delete-elasticsearch-domain --domain-name hello-cdk-es
{
    "DomainStatus": {
        "DomainId": "867065454662/hello-cdk-es",
        "DomainName": "hello-cdk-es",
        "ARN": "arn:aws:es:us-east-1:867065454662:domain/hello-cdk-es",
        "Created": true,
        "Deleted": true,
        "Endpoint": "search-hello-cdk-es-orziggze45iaxzd2wcaz2tdwze.us-east-1.es.amazonaws.com",
        "Processing": true,
        "UpgradeProcessing": false,
        "ElasticsearchVersion": "7.7",
        "ElasticsearchClusterConfig": {
            "InstanceType": "t2.small.elasticsearch",
            "InstanceCount": 1,
            "DedicatedMasterEnabled": false,
            "ZoneAwarenessEnabled": false,
            "WarmEnabled": false
        },
        "EBSOptions": {
            "EBSEnabled": true,
            "VolumeType": "gp2",
            "VolumeSize": 10
        },
        "AccessPolicies": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"es:*\",\"Resource\":\"*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":[\"127.0.0.1\",\"103.5.140.182\"]}}}]}",
        "SnapshotOptions": {},
        "CognitoOptions": {
            "Enabled": false
        },
        "EncryptionAtRestOptions": {
            "Enabled": false
        },
        "NodeToNodeEncryptionOptions": {
            "Enabled": false
        },
        "AdvancedOptions": {
            "rest.action.multi.allow_explicit_index": "true"
        },
        "ServiceSoftwareOptions": {
            "CurrentVersion": "R20201019",
            "NewVersion": "",
            "UpdateAvailable": false,
            "Cancellable": false,
            "UpdateStatus": "COMPLETED",
            "Description": "There is no software update available for this domain.",
            "AutomatedUpdateDate": "1970-01-01T09:00:00+09:00",
            "OptionalDeployment": true
        },
        "DomainEndpointOptions": {
            "EnforceHTTPS": false,
            "TLSSecurityPolicy": "Policy-Min-TLS-1-0-2019-07"
        },
        "AdvancedSecurityOptions": {
            "Enabled": false,
            "InternalUserDatabaseEnabled": false
        }
    }
}

このリクエストを行って、5分程度待った後に以下リクエストを行ってみると、Could not connectメッセージが出て、削除されたことが確認できます。

$ aws es list-domain-names

Could not connect to the endpoint URL: "https://es.us-east-1.amazonaws.com/2015-01-01/domain"

まとめ

Amazon Elasticsearch Serviceの基本的な動作について試してみました。
service定義コードとしてpythonを用いての確認を行うことも出来ました。