alibabacloud-pai-dsw-manage

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PAI DSW Instance Management

PAI DSW实例管理

Manage the full lifecycle of Alibaba Cloud PAI DSW (Data Science Workshop) instances — from provisioning through configuration changes, status monitoring, and start/stop operations. Also supports querying available ECS compute specs.
Architecture:
PAI Workspace + DSW Instance + ECS Spec + Image + VPC + Dataset
API Version:
pai-dsw/2022-01-01

管理阿里云PAI DSW(Data Science Workshop)实例的全生命周期——从资源部署到配置变更、状态监控、启停操作,同时支持查询可用的ECS计算规格。
架构
PAI Workspace + DSW Instance + ECS Spec + Image + VPC + Dataset
API版本
pai-dsw/2022-01-01

Installation

安装

Pre-check: Aliyun CLI >= 3.3.1 required
Run
aliyun version
to verify the version is 3.3.1 or higher. If not installed or the version is too low, see
references/cli-installation-guide.md
for installation instructions.
[MUST] Then run
aliyun configure set --auto-plugin-install true
to enable automatic plugin installation.
bash
undefined
预检查:要求Aliyun CLI版本 >= 3.3.1
运行
aliyun version
确认版本为3.3.1或更高。如果未安装或版本过低,参考
references/cli-installation-guide.md
的安装指引操作。
[必填操作] 随后运行
aliyun configure set --auto-plugin-install true
开启自动插件安装功能。
bash
undefined

macOS (recommended)

macOS(推荐方式)

brew install aliyun-cli
brew install aliyun-cli

Verify version

校验版本

aliyun version
aliyun version

Enable automatic plugin installation

开启自动插件安装

aliyun configure set --auto-plugin-install true
aliyun configure set --auto-plugin-install true

Install pai-dsw plugin

安装pai-dsw插件

aliyun plugin install --names pai-dsw

---
aliyun plugin install --names pai-dsw

---

Authentication

身份认证

Pre-check: Alibaba Cloud Credentials Required
Security Rules:
  • NEVER read, echo, or print AK/SK values (e.g.,
    echo $ALIBABA_CLOUD_ACCESS_KEY_ID
    is FORBIDDEN)
  • NEVER ask the user to input AK/SK directly in the conversation or command line
  • NEVER use
    aliyun configure set
    with literal credential values
  • ONLY use
    aliyun configure list
    to check credential status
bash
aliyun configure list
Check the output for a valid profile (AK, STS, or OAuth identity).
If no valid profile exists, STOP here.
  1. Obtain credentials from Alibaba Cloud Console
  2. Configure credentials outside of this session (via
    aliyun configure
    in a terminal or environment variables in a shell profile)
  3. Return and retry after
    aliyun configure list
    shows a valid profile

预检查:需要阿里云凭证
安全规则:
  • 绝对不要读取、回显或打印AK/SK值(例如禁止执行
    echo $ALIBABA_CLOUD_ACCESS_KEY_ID
  • 绝对不要要求用户在对话或命令行中直接输入AK/SK
  • 绝对不要搭配明文凭证值使用
    aliyun configure set
    命令
  • 仅可使用
    aliyun configure list
    检查凭证状态
bash
undefined
aliyun configure list
> 检查输出中是否存在有效配置文件(AK、STS或OAuth身份)。
>
> **如果没有有效配置文件,请停止操作:**
> 1. 从[阿里云控制台](https://ram.console.aliyun.com/manage/ak)获取凭证
> 2. **在当前会话之外**配置凭证(通过终端执行`aliyun configure`或在Shell配置文件中设置环境变量)
> 3. 待`aliyun configure list`显示有效配置文件后,返回重试即可

---

RAM Permissions

RAM权限

See
references/ram-policies.md
for the complete permission list and minimum-privilege policy.
[MUST] Permission Failure Handling: When any command or API call fails due to permission errors at any point during execution, follow this process:
  1. Read
    references/ram-policies.md
    to get the full list of permissions required by this skill
  2. Use the
    ram-permission-diagnose
    skill to guide the user through requesting the necessary permissions
  3. Pause and wait until the user confirms that the required permissions have been granted

参考
references/ram-policies.md
获取完整权限列表和最小权限策略。
[必填操作]权限错误处理: 执行过程中任意命令或API调用因权限错误失败时,按照以下流程处理:
  1. 查看
    references/ram-policies.md
    获取本技能所需的完整权限列表
  2. 使用
    ram-permission-diagnose
    技能引导用户申请所需权限
  3. 暂停操作,等待用户确认已授予所需权限后再继续

Parameter Confirmation

参数确认

IMPORTANT: Parameter Confirmation — Before executing any command or API call, ALL user-customizable parameters (e.g., RegionId, instance names, CIDR blocks, passwords, domain names, resource specifications, etc.) MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.
ParameterRequiredDescriptionDefault
WorkspaceId
RequiredPAI workspace IDNone — user must provide
InstanceName
RequiredInstance name (letters, digits, underscores only; max 27 chars)None — user must provide
EcsSpec
Required (post-paid)ECS compute spec, e.g.,
ecs.c6.large
. Query via
list-ecs-specs
None
ImageId
Mutually exclusive with
ImageUrl
Image ID from PAI consoleNone
ImageUrl
Mutually exclusive with
ImageId
Container image URL. See
references/common-images.md
for common official images
None
RegionId
RequiredRegion, e.g.,
cn-hangzhou
,
cn-shanghai
None — user must confirm
Accessibility
OptionalVisibility scope:
PUBLIC
(all workspace users) or
PRIVATE
PRIVATE
InstanceId
Required (update/get/start/stop)Instance ID (
dsw-xxxxx
format)
None
VpcId
OptionalVPC ID for private network accessNone
VSwitchId
OptionalVSwitch ID within the VPCNone
SecurityGroupId
OptionalSecurity group IDNone
AcceleratorType
Required (spec query)Accelerator type:
CPU
or
GPU
None — user must confirm
Datasets
OptionalDataset mounts in CLI list format: `DatasetId=<> MountPath=<> MountAccess=RORW`
--read-timeout
OptionalCLI read timeout in seconds (for long-running operations)
10
--connect-timeout
OptionalCLI connection timeout in seconds
10
How to get WorkspaceId: If the user doesn't know their workspace ID, run:
bash
aliyun aiworkspace list-workspaces --region <region> --user-agent AlibabaCloud-Agent-Skills
This returns all workspaces the user has access to. Select the appropriate one based on
WorkspaceName
or ask the user to confirm.

重要提示:参数确认 — 执行任意命令或API调用前,所有用户可自定义参数(例如RegionId、实例名称、CIDR块、密码、域名、资源规格等)必须与用户确认。未经用户明确许可,不得假设或使用默认值。
参数必填说明默认值
WorkspaceId
PAI工作空间ID无,用户必须提供
InstanceName
实例名称(仅支持字母、数字、下划线,最长27个字符)无,用户必须提供
EcsSpec
是(按量付费场景)ECS计算规格,例如
ecs.c6.large
,可通过
list-ecs-specs
查询
ImageId
ImageUrl
二选一
PAI控制台提供的镜像ID
ImageUrl
ImageId
二选一
容器镜像URL,常用官方镜像参考
references/common-images.md
RegionId
地域,例如
cn-hangzhou
cn-shanghai
无,用户必须确认
Accessibility
可选可见范围:
PUBLIC
(所有工作空间用户可见)或
PRIVATE
PRIVATE
InstanceId
是(更新/查询/启动/停止场景)实例ID(格式为
dsw-xxxxx
VpcId
可选私网访问使用的VPC ID
VSwitchId
可选VPC内的交换机ID
SecurityGroupId
可选安全组ID
AcceleratorType
是(规格查询场景)加速器类型:
CPU
GPU
无,用户必须确认
Datasets
可选数据集挂载,CLI列表格式:`DatasetId=<> MountPath=<> MountAccess=RORW`
--read-timeout
可选CLI读超时时间,单位为秒(适用于长时间运行的操作)
10
--connect-timeout
可选CLI连接超时时间,单位为秒
10
如何获取WorkspaceId:如果用户不知道自己的工作空间ID,运行:
bash
undefined
aliyun aiworkspace list-workspaces --region <region> --user-agent AlibabaCloud-Agent-Skills
该命令会返回用户有权限访问的所有工作空间,可根据`WorkspaceName`选择对应项或请用户确认。

参考:[创建和管理工作空间](https://help.aliyun.com/zh/pai/user-guide/create-and-manage-workspaces)

Core Workflow

核心流程

Full command syntax and parameter details:
references/related-commands.md
.
Every
aliyun
CLI command must include
--user-agent AlibabaCloud-Agent-Skills
.
完整命令语法和参数详情参考:
references/related-commands.md
所有
aliyun
CLI命令必须添加
--user-agent AlibabaCloud-Agent-Skills
参数。

1. Query Available ECS Specs

1. 查询可用ECS规格

Run
aliyun pai-dsw list-ecs-specs --accelerator-type <CPU|GPU> --region <region>
to list available compute specs.
[MUST] Region confirmation: The
--region
parameter is required. Spec availability varies by region — always confirm the region with the user before querying.
[MUST] Determine accelerator type correctly:
  • User mentions a spec name (e.g.,
    ecs.hfc6.10xlarge
    ): Query BOTH CPU and GPU types, then match
    InstanceType
    in results. Use the returned
    AcceleratorType
    field to confirm the classification.
  • User specifies image type: GPU image URL (contains
    -gpu-
    or
    cu
    ) → query GPU specs; CPU image URL → query CPU specs.
  • User describes use case only: GPU for 大模型训练/深度学习, CPU for 数据分析/轻量任务. Always confirm with user if ambiguous.
  • [IMPORTANT] Do NOT guess from spec name prefix — the naming convention is unreliable. Always verify via API response.
[MUST] Choose accelerator type based on user requirements:
  • Default recommendation: GPU for 大模型训练/深度学习, CPU for 数据分析/轻量任务
  • Match image type (strong indicator): If user specifies a GPU image URL (contains
    -gpu-
    or
    cu
    ), query GPU specs. If CPU image, query CPU specs.
  • Spec name requires verification: If user mentions a spec name, query both types and find the match in results
  • Always confirm with user before querying if the use case is ambiguous and no spec name is provided
Key response fields:
  • InstanceType
    : Spec name (e.g.,
    ecs.hfc6.10xlarge
    )
  • AcceleratorType
    :
    CPU
    or
    GPU
    — the actual classification from API
  • IsAvailable
    : PRIMARY indicator
    true
    means the spec is available for pay-as-you-go/subscription
  • SpotStockStatus
    : SECONDARY indicator — only for spot instances:
    WithStock
    (available) or
    NoStock
    (unavailable)
  • CPU
    /
    Memory
    /
    GPU
    /
    GPUType
    : Hardware details
  • Price
    : Hourly price in CNY
[MUST] Availability check logic:
  • For pay-as-you-go/subscription: Check
    IsAvailable == true
  • For spot instances: Check
    IsAvailable == true
    AND
    SpotStockStatus == "WithStock"
  • DO NOT use
    SpotStockStatus
    alone to judge availability — many specs have
    IsAvailable: true
    but
    SpotStockStatus: "NoStock"
  • Example:
    ecs.hfc6.10xlarge
    with
    IsAvailable: true, SpotStockStatus: "NoStock"
    Available for pay-as-you-go
运行
aliyun pai-dsw list-ecs-specs --accelerator-type <CPU|GPU> --region <region>
罗列可用计算规格。
[必填操作]地域确认
--region
参数为必填项,不同地域的可用规格不同,查询前必须与用户确认地域。
[必填操作]正确判断加速器类型
  • 用户指定了规格名称(例如
    ecs.hfc6.10xlarge
    ):同时查询CPU和GPU类型,然后匹配结果中的
    InstanceType
    ,使用返回的
    AcceleratorType
    字段确认分类。
  • 用户指定了镜像类型:GPU镜像URL(包含
    -gpu-
    cu
    )→ 查询GPU规格;CPU镜像URL → 查询CPU规格。
  • 用户仅描述了使用场景:大模型训练/深度学习用GPU,数据分析/轻量任务用CPU。如果场景不明确,必须与用户确认
  • [重要提示]不要通过规格名称前缀猜测:命名规则不可靠,必须通过API返回结果验证。
[必填操作]根据用户需求选择加速器类型
  • 默认推荐:大模型训练/深度学习用GPU,数据分析/轻量任务用CPU
  • 匹配镜像类型(强判定指标):如果用户指定的GPU镜像URL包含
    -gpu-
    cu
    ,查询GPU规格;如果是CPU镜像,查询CPU规格。
  • 规格名称需要验证:如果用户提到了规格名称,同时查询两种类型并在结果中查找匹配项
  • 如果使用场景不明确且未提供规格名称,查询前必须与用户确认
关键返回字段
  • InstanceType
    :规格名称(例如
    ecs.hfc6.10xlarge
  • AcceleratorType
    CPU
    GPU
    — API返回的实际分类
  • IsAvailable
    核心判定指标
    true
    表示该规格支持按量付费/包年包月
  • SpotStockStatus
    次要判定指标 — 仅适用于抢占式实例:
    WithStock
    (有库存)或
    NoStock
    (无库存)
  • CPU
    /
    Memory
    /
    GPU
    /
    GPUType
    :硬件详情
  • Price
    :每小时价格,单位为人民币
[必填操作]可用性校验逻辑
  • 按量付费/包年包月场景:检查
    IsAvailable == true
  • 抢占式实例场景:检查
    IsAvailable == true
    SpotStockStatus == "WithStock"
  • 不要仅通过
    SpotStockStatus
    判断可用性 — 很多规格
    IsAvailable: true
    SpotStockStatus: "NoStock"
  • 示例
    ecs.hfc6.10xlarge
    IsAvailable: true, SpotStockStatus: "NoStock"
    支持按量付费

2. Create Instance (check-then-act)

2. 创建实例(先检查再操作)

[MUST] Idempotency guarantee: The CreateInstance API does not support ClientToken, so idempotency is ensured via a check-then-act pattern. Before creating, you must call
list-instances --instance-name <name>
to check if the name already exists.
Step 2.1 — Check existence
bash
aliyun pai-dsw list-instances \
  --instance-name <name> \
  --region <region> \
  --resource-id ALL \
  --user-agent AlibabaCloud-Agent-Skills
Decision logic:
  • TotalCount == 0
    → Name is available, proceed to Step 2.2 to create
  • TotalCount >= 1
    [MUST] Verify exact name match:
    1. Iterate through the returned
      Instances
      array
    2. For each instance, compare its
      InstanceName
      field with the target name character by character (case-sensitive, exact string match)
    3. Exact match found (
      instance.InstanceName === targetName
      ) → Name already exists:
      • Extract the
        InstanceId
        from the matching instance
      • Call
        get-instance --instance-id <id>
        to get full details
      • Compare key parameters (
        EcsSpec
        ,
        ImageUrl
        ,
        Accessibility
        , etc.)
      • Match → Return the existing
        InstanceId
        , do not recreate
      • Mismatch → Ask user to choose a different name
    4. No exact match found (no instance has
      InstanceName === targetName
      ) → Name is available, proceed to Step 2.2 to create
[WARNING] Critical: Exact name match required
The
--instance-name
filter may return partial matches. For example:
  • Query:
    --instance-name llm_train_001
  • Response may include:
    llm_train_001
    ,
    llm_train_001_v2
    ,
    llm_train_001_backup
You MUST verify exact match by checking:
for instance in response.Instances:
    if instance.InstanceName == targetName:  # EXACT string equality
        # Name already exists - DO NOT create
Do NOT assume name is available just because
TotalCount > 0
but you "think" no exact match. If
TotalCount >= 1
, carefully check each instance's InstanceName field.
Step 2.2 — Provision
Run
aliyun pai-dsw create-instance
with required args:
--workspace-id
,
--instance-name
,
--ecs-spec
,
--region
, and either
--image-url
or
--image-id
.
[MUST] Region confirmation: The
--region
parameter is required and must be confirmed with the user. Do NOT use CLI default region without explicit user approval. Spec availability and pricing vary by region.
[MUST] Match EcsSpec with image type:
  • GPU image URL (contains
    -gpu-
    or
    cu
    ) → Must select a GPU spec (e.g.,
    ecs.gn6v-c4g1.xlarge
    )
  • CPU image URL (contains
    -cpu-
    ) → Must select a CPU spec (e.g.,
    ecs.c6.large
    )
  • The spec type MUST match the image type, otherwise the instance will fail to start
  • Use case (大模型训练/数据分析) is only a recommendation, image type is the definitive indicator
Dataset mounting (optional): If the user specifies a dataset to mount, use the
--datasets
parameter in CLI list format:
bash
--datasets DatasetId=<dataset-id> MountPath=<mount-path> MountAccess=RO
[MUST] Dataset parameters require explicit user confirmation — do NOT assume or auto-generate dataset configurations.
Official images:
references/common-images.md
.
Advanced usage (VPC, datasets):
references/related-commands.md
.
Response:
{"InstanceId": "dsw-xxxxx", ...}
[IMPORTANT] Return immediately after creation: After
create-instance
returns
InstanceId
, do NOT block waiting for
Running
status
. Instead:
  1. Return the
    InstanceId
    and current status (
    Creating
    ) to the user immediately
  2. Provide the user with a command to check status later:
    bash
    aliyun pai-dsw get-instance --instance-id <instance-id> --user-agent AlibabaCloud-Agent-Skills
  3. Inform the user that instance startup typically takes 2–5 minutes
Why this matters: Blocking polling prevents the agent from responding to other user requests. DSW instance creation is a long-running operation; the agent should return control to the user promptly.
[必填操作]幂等性保证:CreateInstance API不支持ClientToken,因此通过先检查再操作的模式保证幂等性。创建前必须调用
list-instances --instance-name <name>
检查名称是否已存在。
步骤2.1 — 检查存在性
bash
aliyun pai-dsw list-instances \\
  --instance-name <name> \\
  --region <region> \\
  --resource-id ALL \\
  --user-agent AlibabaCloud-Agent-Skills
判定逻辑
  • TotalCount == 0
    → 名称可用,进入步骤2.2执行创建
  • TotalCount >= 1
    [必填操作]校验精确名称匹配
    1. 遍历返回的
      Instances
      数组
    2. 逐个比较实例的
      InstanceName
      字段和目标名称逐字符匹配(大小写敏感,精确字符串匹配)
    3. 找到精确匹配项
      instance.InstanceName === targetName
      )→ 名称已存在:
      • 提取匹配实例的
        InstanceId
      • 调用
        get-instance --instance-id <id>
        获取完整详情
      • 对比核心参数(
        EcsSpec
        ImageUrl
        Accessibility
        等)
      • 参数匹配 → 返回已存在的
        InstanceId
        不要重复创建
      • 参数不匹配 → 请用户选择其他名称
    4. 未找到精确匹配项(没有实例的
      InstanceName === targetName
      )→ 名称可用,进入步骤2.2执行创建
[警告]关键要求:必须精确匹配名称
--instance-name
筛选器可能返回部分匹配结果,例如:
  • 查询参数:
    --instance-name llm_train_001
  • 响应可能包含:
    llm_train_001
    llm_train_001_v2
    llm_train_001_backup
必须通过以下校验确认精确匹配
for instance in response.Instances:
    if instance.InstanceName == targetName:  # 精确字符串相等
        # 名称已存在 - 不要创建
不要因为
TotalCount > 0
但你“认为”没有精确匹配就判定名称可用。如果
TotalCount >= 1
必须仔细检查每个实例的InstanceName字段
步骤2.2 — 资源部署
运行
aliyun pai-dsw create-instance
并传入必填参数:
--workspace-id
--instance-name
--ecs-spec
--region
,以及
--image-url
--image-id
二选一。
[必填操作]地域确认
--region
参数为必填项,必须与用户确认。未经用户明确许可,不要使用CLI默认地域。不同地域的规格可用性和定价不同。
[必填操作]EcsSpec与镜像类型匹配
  • GPU镜像URL(包含
    -gpu-
    cu
    )→ 必须选择GPU规格(例如
    ecs.gn6v-c4g1.xlarge
  • CPU镜像URL(包含
    -cpu-
    )→ 必须选择CPU规格(例如
    ecs.c6.large
  • 规格类型必须与镜像类型匹配,否则实例将启动失败
  • 使用场景(大模型训练/数据分析)仅为推荐,镜像类型是最终判定指标
数据集挂载(可选):如果用户指定要挂载数据集,使用CLI列表格式的
--datasets
参数:
bash
--datasets DatasetId=<dataset-id> MountPath=<mount-path> MountAccess=RO
[必填操作] 数据集参数需要用户明确确认 — 不要假设或自动生成数据集配置。
官方镜像参考:
references/common-images.md
高级用法(VPC、数据集)参考:
references/related-commands.md
返回结果
{"InstanceId": "dsw-xxxxx", ...}
[重要提示]创建完成后立即返回
create-instance
返回
InstanceId
后,不要阻塞等待
Running
状态
,而是:
  1. 立即将
    InstanceId
    和当前状态(
    Creating
    )返回给用户
  2. 为用户提供后续查询状态的命令:
    bash
    aliyun pai-dsw get-instance --instance-id <instance-id> --user-agent AlibabaCloud-Agent-Skills
  3. 告知用户实例启动通常需要2-5分钟
设计原因:阻塞轮询会阻止Agent响应其他用户请求。DSW实例创建是长时间运行的操作,Agent应及时将控制权交还给用户。

3. List Instances

3. 罗列实例

Run
aliyun pai-dsw list-instances
. Filter by
--workspace-id
or
--status
; paginate with
--page-number
/
--page-size
.
运行
aliyun pai-dsw list-instances
,可通过
--workspace-id
--status
筛选,通过
--page-number
/
--page-size
分页。

4. Get Instance Details

4. 获取实例详情

Run
aliyun pai-dsw get-instance --instance-id <id>
to check instance status and details.
When to poll: Only poll when the user explicitly asks to wait for a status change (e.g., "wait until it's running"). Otherwise, return the current status immediately.
Timeout limits: Maximum 60 polls (30 minutes total). If exceeded, stop and prompt user to check manually.
Polling interval: 10–30 seconds between calls.
CLI timeout: For long-running operations, increase read timeout:
bash
aliyun pai-dsw get-instance --instance-id <id> --read-timeout 30 --user-agent AlibabaCloud-Agent-Skills
Once
Status == "Running"
, access the instance via
InstanceUrl
.
For complete status transitions, see Instance Status Values in
references/related-commands.md
.
运行
aliyun pai-dsw get-instance --instance-id <id>
查询实例状态和详情。
轮询触发条件:仅当用户明确要求等待状态变更时(例如“等它运行起来”)才进行轮询,否则立即返回当前状态。
超时限制:最多轮询60次(总计30分钟),超时后停止并提示用户手动检查。
轮询间隔:两次调用间隔10-30秒。
CLI超时配置:对于长时间运行的操作,增大读超时时间:
bash
aliyun pai-dsw get-instance --instance-id <id> --read-timeout 30 --user-agent AlibabaCloud-Agent-Skills
Status == "Running"
时,可通过
InstanceUrl
访问实例。
完整状态流转参考
references/related-commands.md
中的实例状态值说明。

5. Stop Instance

5. 停止实例

Run
aliyun pai-dsw stop-instance --instance-id <id>
.
Status transition:
Running
Stopping
Stopped
Save environment image: To save the environment as a custom image before stopping, use the PAI Console. See Create a DSW Instance Image for instructions.
运行
aliyun pai-dsw stop-instance --instance-id <id>
状态流转
Running
Stopping
Stopped
保存环境镜像:如果需要在停止前将环境保存为自定义镜像,可使用PAI控制台操作,参考创建DSW实例镜像获取指引。

6. Update Instance

6. 更新实例

Run
aliyun pai-dsw update-instance --instance-id <id>
to modify
--instance-name
,
--ecs-spec
,
--image-id
,
--accessibility
,
--datasets
, etc.
[MUST] Before updating:
  1. Call
    get-instance
    to check current status and configuration
  2. Check if update is needed:
    • For
      --ecs-spec
      : Compare current
      EcsSpec
      with target spec. If already equal, skip update and inform user
    • For
      --image-id
      /
      --image-url
      : Compare current
      ImageId
      /
      ImageUrl
      with target
    • For
      --instance-name
      : Compare current
      InstanceName
      with target
  3. If already at target configuration, return current instance info — do not call update-instance
  4. If update is needed, use
    --start-instance true
    to auto-start after update
[IMPORTANT] Always update the specified instance by its
InstanceId
. Do NOT substitute with another instance that already has the target spec — the user's request is to upgrade the specific instance, not to find an alternative.
运行
aliyun pai-dsw update-instance --instance-id <id>
修改
--instance-name
--ecs-spec
--image-id
--accessibility
--datasets
等参数。
[必填操作]更新前检查
  1. 调用
    get-instance
    检查当前状态和配置
  2. 检查是否需要更新
    • 对于
      --ecs-spec
      :对比当前
      EcsSpec
      和目标规格,如果已经一致,跳过更新并告知用户
    • 对于
      --image-id
      /
      --image-url
      :对比当前
      ImageId
      /
      ImageUrl
      和目标值
    • 对于
      --instance-name
      :对比当前
      InstanceName
      和目标名称
  3. 如果已经是目标配置,返回当前实例信息 — 不要调用update-instance
  4. 如果需要更新,使用
    --start-instance true
    参数在更新完成后自动启动实例
[重要提示] 始终通过
InstanceId
更新指定实例,不要替换为其他已经符合目标规格的实例 — 用户的需求是升级指定实例,而不是寻找替代实例。

7. Start Instance

7. 启动实例

Run
aliyun pai-dsw start-instance --instance-id <id>
, then poll (Step 4) until
Running
.
Prerequisite: Instance must be in
Stopped
or
Failed
state. Call
get-instance
to confirm before starting.

运行
aliyun pai-dsw start-instance --instance-id <id>
,然后按照步骤4的逻辑轮询直到状态变为
Running
前置条件:实例必须处于
Stopped
Failed
状态,启动前调用
get-instance
确认。

Success Verification

成功校验

Full verification steps:
references/verification-method.md
.
Quick check:
get-instance
should return
Status == "Running"
with a non-empty
InstanceUrl
.

完整校验步骤参考:
references/verification-method.md
快速校验:
get-instance
返回
Status == "Running"
InstanceUrl
不为空。

Cleanup

清理

This skill does not expose instance deletion (irreversible operation — use the console).
To stop incurring charges, stop the instance via Step 5 (
stop-instance
).

本技能不开放实例删除功能(不可逆操作,请通过控制台操作)。
如果要停止计费,通过步骤5的
stop-instance
命令停止实例即可。

Best Practices

最佳实践

  1. Always run check-then-act before creation — use
    list-instances --instance-name <name>
    to avoid duplicate-instance errors.
  2. Prefer
    PRIVATE
    visibility
    — prevents accidental operations by other workspace users.
  3. Check instance status before update — call
    get-instance
    first; some parameters require Stopped state, others can be updated while Running.
  4. Use
    --resource-id ALL
    with
    list-instances
    — the default only returns post-paid instances.
  5. Observe polling timeout limits — see Step 4 for timeout and interval guidance.
  6. Verify spec availability before provisioning — run
    list-ecs-specs
    to confirm the spec is available in the target region.
  7. Tag instances with Labels — simplifies batch queries and lifecycle management.

  1. 创建前始终执行先检查再操作 — 使用
    list-instances --instance-name <name>
    避免重复实例错误。
  2. 优先使用
    PRIVATE
    可见性
    — 避免其他工作空间用户误操作。
  3. 更新前检查实例状态 — 先调用
    get-instance
    ;部分参数要求实例处于Stopped状态,其他参数可在Running状态下更新。
  4. list-instances
    搭配
    --resource-id ALL
    使用
    — 默认仅返回按量付费实例。
  5. 遵守轮询超时限制 — 参考步骤4的超时和间隔指引。
  6. 部署前校验规格可用性 — 运行
    list-ecs-specs
    确认目标地域下该规格可用。
  7. 为实例添加标签 — 简化批量查询和生命周期管理。

References

参考文档

DocumentPath
CLI Installation
references/cli-installation-guide.md
RAM Policies
references/ram-policies.md
CLI Commands
references/related-commands.md
Verification
references/verification-method.md
Acceptance Criteria
references/acceptance-criteria.md
Common Images
references/common-images.md
PAI DSW API Overviewhelp.aliyun.com
文档路径
CLI安装
references/cli-installation-guide.md
RAM策略
references/ram-policies.md
CLI命令
references/related-commands.md
校验方法
references/verification-method.md
验收标准
references/acceptance-criteria.md
常用镜像
references/common-images.md
PAI DSW API概览help.aliyun.com
",