ALIYUN::PaiDswApi::Instance

ALIYUN::PaiDswApi::Instance类型用于创建一个DSW实例。

语法

{
  "Type": "ALIYUN::PaiDswApi::Instance",
  "Properties": {
    "Datasets": List,
    "InstanceName": String,
    "EnvironmentVariables": Map,
    "Accessibility": String,
    "WorkspaceId": String,
    "ImageUrl": String,
    "EcsSpec": String,
    "Labels": List,
    "SaveImage": Boolean,
    "UserVpc": Map
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

Datasets

List

数据集集合。

InstanceName

String

实例名称。

格式要求:

  • 只能包含英文字母、数字和下划线(_)。

  • 不能超过27个字符。

EnvironmentVariables

Map

环境变量。

Accessibility

String

工作空间内是否他人可见。

取值:

  • PRIVATE:表示工作空间内自己及管理员可见。

  • PUBLIC:工作空间所有用户可见。

WorkspaceId

String

工作空间ID。

如何获取工作空间ID,请参见ListWorkspaces - 获取工作空间列表

ImageUrl

String

镜像地址。

如何获取镜像地址,请参见ListImages - 获取镜像列表

EcsSpec

String

实例对应的ECS规格。

如何获取ECS规格,请参见ListEcsSpecs - 获取ECS规格列表

Labels

List

用户自定义标签。

SaveImage

Boolean

保存环境后是否关闭实例。

取值:

  • true:保存环境后关闭实例。

  • false:保存环境后不关闭实例。

UserVpc

Map

User VPC配置。

Datasets语法

"Datasets": [
  {
    "MountPath": String,
    "DatasetId": String
  }
]

Datasets属性

属性名称

类型

必须

允许更新

描述

约束

MountPath

String

容器内挂载路径。

DatasetId

String

数据集ID。

如何获取数据集ID,请参见ListDatasets - 获取数据集列表

Labels语法

"Labels": [
  {
    "Value": String,
    "Key": String
  }
]

Labels属性

属性名称

类型

必须

允许更新

描述

约束

Value

String

用户定义标签值。

长度为0~128个字符,不能以aliyunacs:开头,不能包含http://https://

Key

String

用户定义标签键。

长度为1~128个字符,不能以aliyunacs:开头,不能包含http://https://

UserVpc语法

"UserVpc": {
  "VpcId": String,
  "SecurityGroupId": String
}

UserVpc属性

属性名称

类型

必须

允许更新

描述

约束

VpcId

String

VPC ID。

SecurityGroupId

String

安全组ID。

返回值

Fn::GetAtt

  • Datasets:数据集集合。

  • InstanceName:实例名称。

  • EnvironmentVariables:环境变量。

  • Accessibility:工作空间内是否他人可见。

  • InstanceId:实例ID。

  • WorkspaceId:工作空间ID。

  • ImageUrl:镜像地址。

  • PaymentType:资源的支付类型。

  • EcsSpec:实例对应的ECS规格。

  • Labels:用户自定义标签。

  • UserVpc:User VPC配置。

  • JupyterlabUrl:Jupyterlab Url。

  • TerminalUrl:终端Url。

  • InstanceUrl:实例Url。

  • WebIDEUrl:Web IDE Url。

示例

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  EcsSpec:
    Description: The ECS specification of the instance.
    Type: String
    Default: ecs.gn5-c28g1.7xlarge
  ImageUrl:
    Description: The mirror address.
    Type: String
    Default: registry-vpc.cn-shanghai.aliyuncs.com/******/pai:python_3.8.10-tensorflow_2.9.0
  InstanceName:
    AllowedPattern: ^[_a-zA-Z0-9]{1,27}$
    Description: 'The instance name. Format requirements:

      - Can only contain letters, numbers and underscores (_).

      - It cannot exceed 27 characters.'
    Type: String
Resources:
  ExtensionResource:
    Properties:
      EcsSpec:
        Ref: EcsSpec
      ImageUrl:
        Ref: ImageUrl
      InstanceName:
        Ref: InstanceName
    Type: ALIYUN::PaiDswApi::Instance
Outputs:
  Accessibility:
    Description: Whether the workspace is visible to others.
    Value:
      Fn::GetAtt:
      - ExtensionResource
      - Accessibility
  Datasets:
    Description: A collection of datasets.
    Value:
      Fn::GetAtt:
      - ExtensionResource
      - Datasets
  EcsSpec:
    Description: The ECS specification of the instance.
    Value:
      Fn::GetAtt:
      - ExtensionResource
      - EcsSpec
  EnvironmentVariables:
    Description: Environment variable.
    Value:
      Fn::GetAtt:
      - ExtensionResource
      - EnvironmentVariables
  ImageUrl:
    Description: The mirror address.
    Value:
      Fn::GetAtt:
      - ExtensionResource
      - ImageUrl
  InstanceId:
    Description: The first ID of the resource.
    Value:
      Fn::GetAtt:
      - ExtensionResource
      - InstanceId
  InstanceName:
    Description: The instance name.
    Value:
      Fn::GetAtt:
      - ExtensionResource
      - InstanceName
  Labels:
    Description: User-defined labels.
    Value:
      Fn::GetAtt:
      - ExtensionResource
      - Labels
  PaymentType:
    Description: The payment type of the resource.
    Value:
      Fn::GetAtt:
      - ExtensionResource
      - PaymentType
  UserVpc:
    Description: User vpc configuration.
    Value:
      Fn::GetAtt:
      - ExtensionResource
      - UserVpc
  WorkspaceId:
    Description: The Id of the workspace.
    Value:
      Fn::GetAtt:
      - ExtensionResource
      - WorkspaceId

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "EcsSpec": {
      "Description": "The ECS specification of the instance.",
      "Type": "String",
      "Default": "ecs.gn5-c28g1.7xlarge"
    },
    "ImageUrl": {
      "Description": "The mirror address.",
      "Type": "String",
      "Default": "registry-vpc.cn-shanghai.aliyuncs.com/******/pai:python_3.8.10-tensorflow_2.9.0"
    },
    "InstanceName": {
      "AllowedPattern": "^[_a-zA-Z0-9]{1,27}$",
      "Description": "The instance name. Format requirements:\n- Can only contain letters, numbers and underscores (_).\n- It cannot exceed 27 characters.",
      "Type": "String"
    }
  },
  "Resources": {
    "ExtensionResource": {
      "Properties": {
        "EcsSpec": {
          "Ref": "EcsSpec"
        },
        "ImageUrl": {
          "Ref": "ImageUrl"
        },
        "InstanceName": {
          "Ref": "InstanceName"
        }
      },
      "Type": "ALIYUN::PaiDswApi::Instance"
    }
  },
  "Outputs": {
    "Accessibility": {
      "Description": "Whether the workspace is visible to others.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Accessibility"
        ]
      }
    },
    "Datasets": {
      "Description": "A collection of datasets.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Datasets"
        ]
      }
    },
    "EcsSpec": {
      "Description": "The ECS specification of the instance.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "EcsSpec"
        ]
      }
    },
    "EnvironmentVariables": {
      "Description": "Environment variable.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "EnvironmentVariables"
        ]
      }
    },
    "ImageUrl": {
      "Description": "The mirror address.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "ImageUrl"
        ]
      }
    },
    "InstanceId": {
      "Description": "The first ID of the resource.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "InstanceId"
        ]
      }
    },
    "InstanceName": {
      "Description": "The instance name.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "InstanceName"
        ]
      }
    },
    "Labels": {
      "Description": "User-defined labels.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Labels"
        ]
      }
    },
    "PaymentType": {
      "Description": "The payment type of the resource.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "PaymentType"
        ]
      }
    },
    "UserVpc": {
      "Description": "User vpc configuration.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "UserVpc"
        ]
      }
    },
    "WorkspaceId": {
      "Description": "The Id of the workspace.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "WorkspaceId"
        ]
      }
    }
  }
}