Elasticsearch Instance Management
Manage Alibaba Cloud Elasticsearch instances: create, describe, list, restart, upgrade/downgrade configuration, and query node information.
Architecture
Alibaba Cloud Elasticsearch Instance Management
├── createInstance (Create Instance)
├── DescribeInstance (Query Instance Details)
├── ListInstance (List Instances)
├── ListAllNode (Query Cluster Node Info)
├── RestartInstance (Restart Instance)
└── UpdateInstance (Upgrade/Downgrade Instance Configuration)
Prerequisites
Pre-check: Aliyun CLI >= 3.3.1 required
Run aliyun version to verify >= 3.3.1. If not installed or version too low,
see references/cli-installation-guide.md for installation instructions.
Then [MUST] run aliyun configure set --auto-plugin-install true to enable automatic plugin installation.
CODEBLOCK1
Authentication
Pre-check: Alibaba Cloud Credentials Required
Security Rules (MUST FOLLOW):
- - NEVER read, echo, or print AK/SK values
- NEVER ask the user to input AK/SK directly in the conversation
- NEVER use
aliyun configure set with literal credential values - NEVER accept AK/SK provided directly by users in the conversation
- ONLY read credentials from environment variables or pre-configured CLI profiles
⚠️ CRITICAL: Handling User-Provided Credentials
If a user attempts to provide AK/SK directly (e.g., "My AK is xxx, SK is yyy"):
- 1. STOP immediately - Do NOT execute any command
- Reject the request politely with the following message:
> For your account security, please do not provide Alibaba Cloud AccessKey ID and AccessKey Secret directly in the conversation.
>
> Please use the following secure methods to configure credentials:
>
> Method 1: Interactive configuration via aliyun configure (Recommended)
> aliyun configure
> # Enter AK/SK as prompted, credentials will be securely stored in local config file
>
> Method 2: Configure via environment variables
> export ALIBABA_CLOUD_ACCESS_KEY_ID=<your-access-key-id>
> export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<your-access-key-secret>
>
> After configuration, please retry your request.
>
- 3. Do NOT proceed with any Alibaba Cloud operations until credentials are properly configured
Check CLI configuration:
> aliyun configure list
>
Check the output for a valid profile (AK, STS, or OAuth identity).
If no valid credentials exist, STOP here.
RAM Policy
Ensure the RAM user has the required permissions. See references/ram-policies.md for detailed policy configurations.
Minimum Required Permissions:
- - INLINECODE3
- INLINECODE4
- INLINECODE5
- INLINECODE6
- INLINECODE7
- INLINECODE8
Core Workflow
Note: Elasticsearch APIs use ROA (RESTful) style. You can use --body to specify the HTTP request body as a JSON string. See examples in each task below.
Idempotency: For write operations (create, restart, delete, etc.), you MUST use the --client-token parameter to ensure idempotency.
- - Use a UUID format unique identifier as clientToken
- When a request times out or fails, you can safely retry with the same clientToken. When retrying after timeout, it is recommended to wait 10 seconds before retrying
- Duplicate requests with the same clientToken will not execute the operation repeatedly
- Generation method: Prefer using uuidgen or PowerShell GUID; if the environment doesn't support it, generate a UUID format string directly; if strict randomness is not required, use idem-timestamp-semantic-identifier as a fallback. Do not interrupt the process due to unavailable commands.
Task 1: Create Elasticsearch Instance
node-specifications-by-region.md Different roles in different regions support different specifications when creating instances, refer to this document.
⚠️ CRITICAL: Required Parameters and Region Validation
When creating an ES instance, parameters such as --region, esAdminPassword, vpcId, vswitchId, vsArea, paymentType MUST be explicitly provided by the user.
Important Notes:
- - The
--region parameter MUST NOT be guessed or use default values - If the user does not provide a region or provides an invalid region, you MUST clearly prompt the user to provide a valid region
For detailed validation rules, refer to related-apis.md - createInstance Required Parameters and Region Validation
Method 2: Using --body to specify HTTP request body (RESTful style)
CODEBLOCK4
Example: Create Single Availability Zone Instance
CODEBLOCK5
Example: Create Multi-Availability Zone Instance
- 1. For multi-AZ instances, networkConfig.vswitchId only supports the primary availability zone vSwitch, and networkConfig.vsArea only supports the primary availability zone name. Nodes will be automatically distributed to different availability zones. Do not specify availability zones and vSwitches through zoneInfos when creating, let the cloud provider allocate automatically.
- Specify the number of availability zones through zoneCount. For multi-AZ instances, you must create master nodes.
CODEBLOCK6
Error Handling
- 1. When an error occurs indicating that order parameters do not meet validation conditions, it may be due to incorrect data node specifications. You should prompt the user to use the correct specifications and not guess on your own. Refer to the specifications document node-specifications-by-region.md
Task 2: Describe Instance Details
⚠️ Important: Required Parameters Must Be Provided by User
When querying instance details, --region and --instance-id must be explicitly provided by the user. Do not guess the region.
For detailed instructions, refer to related-apis.md - DescribeInstance Required Parameters
CODEBLOCK7
Example:
CODEBLOCK8
Task 3: List Instances
⚠️ Important: Required Parameters and Parameter Validation
CODEBLOCK9
For detailed parameters, filter examples, and response format, refer to related-apis.md - ListInstance
Task 4: Restart Instance
⚠️ CRITICAL: Pre-restart Check Requirements
Before executing a restart operation, you must first query the instance status and confirm it is active:
Pre-check Rules:
- - Only when the instance status is
active can you execute the restart operation - If the instance status is abnormal (such as
activating, inactive, invalid, etc.), restart operation is prohibited - If the instance status is abnormal, you should inform the user that the current status is not suitable for restart and recommend waiting for the instance to recover or contacting Alibaba Cloud technical support
Using --body to specify HTTP request body (RESTful style)
CODEBLOCK10
Example (using --body):
CODEBLOCK11
Task 5: Update Instance Configuration (Upgrade/Downgrade)
⚠️ CRITICAL: Pre-update Check Requirements
Before executing an update operation, you must first query the instance status and confirm it is active:
- - Only when the instance status is
active can you execute the update operation - If the instance status is abnormal (such as
activating, inactive, invalid), update operation is prohibited - If the instance status is abnormal, inform the user that the current status is not suitable for configuration change and recommend waiting for the instance to recover
Important Constraints:
- - Each update call can only change one type of node (data node, dedicated master node, cold data node, coordinating node, Kibana node, or elastic node)
- Upgrade: Cannot reduce storage size, storage type, node count, or spec CPU/memory
- Downgrade: Cannot increase storage size, storage type, node count, or spec CPU/memory. The
orderActionType query parameter MUST be set to downgrade. Cannot reduce node count via this API (use ShrinkNode instead). Force change and updateType are not supported for downgrade - Storage size reduction is not supported in either direction
- Enabled nodes cannot be disabled
For detailed API usage, parameters, and examples, refer to related-apis.md - UpdateInstance
node-specifications-by-region.md Different roles in different regions support different specifications, refer to this document.
CLI Command (using --body for RESTful HTTP body):
CODEBLOCK12
Example: Upgrade data node spec
CODEBLOCK13
Example: Downgrade data node spec (must set orderActionType=downgrade)
CODEBLOCK14
Request Body Examples:
The following examples show the --body JSON for each common upgrade/downgrade scenario.
Note: Each call can only change one type of node. For data nodes, nodeAmount and nodeSpec are considered the same type and can be combined in one call.
| # | Scenario | Request Body (--body) |
|---|
| 1 | Data node disk upgrade/downgrade | INLINECODE42 |
| 2 |
Data node spec upgrade/downgrade |
{"nodeSpec":{"spec":"elasticsearch.sn2ne.xlarge.new"}} |
| 3 | Data node disk + spec together |
{"nodeSpec":{"spec":"elasticsearch.sn2ne.xlarge.new","disk":40}} |
| 4 | Data node count increase/decrease |
{"nodeAmount":4} |
| 5 | Data node count + disk + spec together |
{"nodeAmount":4,"nodeSpec":{"spec":"elasticsearch.sn2ne.xlarge.new","disk":40}} |
| 6 | Master node spec upgrade/downgrade |
{"masterConfiguration":{"spec":"elasticsearch.sn2ne.xlarge"}} |
| 7 | Kibana node spec change |
{"kibanaConfiguration":{"spec":"elasticsearch.sn1ne.large"}} |
| 8 | Coordinating node count + spec |
{"clientNodeConfiguration":{"amount":3,"spec":"elasticsearch.sn1ne.large"}} |
| 9 | Cold node count + disk + spec |
{"warmNodeConfiguration":{"amount":3,"spec":"elasticsearch.sn1ne.large","disk":500}} |
Error Handling
- 1. When an error occurs indicating order parameters do not meet validation conditions, it may be due to incorrect node specifications. Refer to node-specifications-by-region.md
- If the instance status is not
active, prompt the user to wait for the instance to recover before retrying - If attempting to change multiple node types at once, inform the user that only one node type can be changed per operation
Task 6: List All Nodes (Query Cluster Node Information)
CODEBLOCK15
Parameters:
| Parameter | Required | Description |
|---|
| INLINECODE52 | Yes | Instance ID |
| INLINECODE53 |
No | Whether to return node monitoring information, default true |
Example:
CODEBLOCK16
Response Fields:
| Field | Description |
|---|
| INLINECODE54 | Node IP address |
| INLINECODE55 |
Node type: MASTER/WORKER/WORKER_WARM/COORDINATING/KIBANA |
|
health | Node health status: GREEN/YELLOW/RED/GRAY |
|
cpuPercent | CPU usage rate |
|
heapPercent | JVM memory usage rate |
|
diskUsedPercent | Disk usage rate |
|
loadOneM | One minute load |
|
zoneId | Availability zone where the node is located |
|
port | Node access port |
Success Verification
See references/verification-method.md for detailed verification steps.
Quick Verification:
CODEBLOCK17
Expected status: active
Reference Links
RAM permission policies |
|
verification-method.md | Verification steps |
|
acceptance-criteria.md | Correct/incorrect patterns |
|
cli-installation-guide.md | CLI installation guide |
|
node-specifications-by-region.md | Node specifications by region and role |
|
Elasticsearch Product Page | Official product page |
|
Elasticsearch API Reference | Official API reference |
Elasticsearch实例管理
管理阿里云Elasticsearch实例:创建、查询、列表、重启、升级/降级配置以及查询节点信息。
架构
阿里云Elasticsearch实例管理
├── createInstance (创建实例)
├── DescribeInstance (查询实例详情)
├── ListInstance (实例列表)
├── ListAllNode (查询集群节点信息)
├── RestartInstance (重启实例)
└── UpdateInstance (升级/降级实例配置)
前置条件
预检查:需要Aliyun CLI >= 3.3.1
运行 aliyun version 验证版本是否 >= 3.3.1。如果未安装或版本过低,
请参阅 references/cli-installation-guide.md 获取安装说明。
然后 [必须] 运行 aliyun configure set --auto-plugin-install true 启用自动插件安装。
bash
验证CLI版本
aliyun version
启用自动插件安装
aliyun configure set --auto-plugin-install true
认证
预检查:需要阿里云凭证
安全规则(必须遵守):
- - 绝不读取、回显或打印AK/SK值
- 绝不要求用户在对话中直接输入AK/SK
- 绝不使用字面凭证值执行 aliyun configure set
- 绝不接受用户在对话中直接提供的AK/SK
- 仅从环境变量或预配置的CLI配置文件中读取凭证
⚠️ 关键:处理用户提供的凭证
如果用户尝试直接提供AK/SK(例如:我的AK是xxx,SK是yyy):
- 1. 立即停止 - 不执行任何命令
- 礼貌拒绝请求,并回复以下消息:
为了您的账户安全,请不要在对话中直接提供阿里云AccessKey ID和AccessKey Secret。
请使用以下安全方式配置凭证:
方式1:通过aliyun configure交互式配置(推荐)
aliyun configure
# 根据提示输入AK/SK,凭证将安全存储在本地配置文件中
方式2:通过环境变量配置
export ALIBABACLOUDACCESSKEYID=
export ALIBABACLOUDACCESSKEYSECRET=
配置完成后,请重试您的请求。
- 3. 在凭证正确配置之前,不要继续任何阿里云操作
检查CLI配置:
bash
aliyun configure list
检查输出中是否存在有效的配置文件(AK、STS或OAuth身份)。
如果没有有效的凭证,在此停止。
RAM策略
确保RAM用户拥有所需权限。有关详细的策略配置,请参阅 references/ram-policies.md。
最低所需权限:
- - elasticsearch:CreateInstance
- elasticsearch:DescribeInstance
- elasticsearch:ListInstance
- elasticsearch:ListAllNode
- elasticsearch:RestartInstance
- elasticsearch:UpdateInstance
核心工作流
注意: Elasticsearch API使用 ROA(RESTful) 风格。您可以使用 --body 将HTTP请求体指定为JSON字符串。请参阅下方每个任务中的示例。
幂等性: 对于写操作(创建、重启、删除等),您必须使用 --client-token 参数以确保幂等性。
- - 使用UUID格式的唯一标识符作为clientToken
- 当请求超时或失败时,您可以使用相同的clientToken安全地重试。超时后重试时,建议等待10秒再重试
- 使用相同clientToken的重复请求不会重复执行操作
- 生成方法:优先使用uuidgen或PowerShell GUID;如果环境不支持,直接生成UUID格式字符串;如果不需要严格随机性,可使用idem-timestamp-semantic-identifier作为后备。不要因命令不可用而中断流程。
任务1:创建Elasticsearch实例
node-specifications-by-region.md 不同地域的不同角色在创建实例时支持不同的规格,请参考此文档。
⚠️ 关键:必需参数和地域验证
创建ES实例时,--region、esAdminPassword、vpcId、vswitchId、vsArea、paymentType等参数必须由用户明确提供。
重要说明:
- - --region 参数不得猜测或使用默认值
- 如果用户未提供地域或提供了无效地域,您必须明确提示用户提供有效地域
有关详细的验证规则,请参阅 related-apis.md - createInstance 必需参数和地域验证
方法2:使用 --body 指定HTTP请求体(RESTful风格)
bash
首先生成幂等令牌
CLIENT_TOKEN=$(uuidgen)
aliyun elasticsearch create-instance \
--region \
--client-token $CLIENT_TOKEN \
--body {
esAdminPassword: ,
esVersion: 7.10withX-Pack,
nodeAmount: 2,
nodeSpec: {disk: 20, diskType: cloud_ssd,spec: elasticsearch.sn2ne.large.new},
networkConfig: {vpcId: ,vswitchId: , vsArea: , type: vpc},
paymentType: postpaid,
description:
} \
--connect-timeout 3 \
--read-timeout 10 \
--user-agent AlibabaCloud-Agent-Skills
示例:创建单可用区实例
bash
生成幂等令牌(超时后重试时使用相同令牌)
CLIENT_TOKEN=$(uuidgen)
aliyun elasticsearch create-instance \
--region cn-hangzhou \
--client-token $CLIENT_TOKEN \
--body {
esAdminPassword: YourPassword123!,
esVersion: 7.10withX-Pack,
nodeAmount: 2,
nodeSpec: {
disk: 20,
diskType: cloud_ssd,
spec: elasticsearch.sn2ne.large.new
},
networkConfig: {
vpcId: vpc-bp1xxx,
vswitchId: vsw-bp1xxx,
vsArea: cn-hangzhou-i,
type: vpc
},
paymentType: postpaid,
description: my-es-instance,
kibanaConfiguration: {
spec: elasticsearch.sn1ne.large,
amount: 1,
disk: 0
}
} \
--connect-timeout 3 \
--read-timeout 10 \
--user-agent AlibabaCloud-Agent-Skills
示例:创建多可用区实例
- 1. 对于多可用区实例,networkConfig.vswitchId仅支持主可用区vSwitch,networkConfig.vsArea仅支持主可用区名称。节点将自动分布到不同可用区。创建时不要通过zoneInfos指定可用区和vSwitch,让云供应商自动分配。
- 通过zoneCount指定可用区数量。对于多可用区实例,必须创建专有主节点。
bash
生成幂等令牌
CLIENT_TOKEN=$(uuidgen)
aliyun elasticsearch create-instance \
--region cn-hangzhou \
--client-token $CLIENT_TOKEN \
--body {
esAdminPassword: YourPassword123!,
esVersion: 7.10withX-Pack,
nodeAmount: 2,
nodeSpec: {
disk: 20,
diskType: cloud_ssd,
spec: elasticsearch.sn2ne.large.new
},
networkConfig: {
vpcId: vpc-bp1xxx, vswitchId: vsw-bp1xxx, vsArea: cn-hangzhou-i, type: vpc
},
paymentType: postpaid,
description: my-es-instance,
zoneCount: 2,
kibanaConfiguration: {
spec: elasticsearch.sn1ne.large,
amount: 1
},
masterConfiguration: {
amount: 3,
disk: 20,