从 Amazon CLI 中设置默认值 - Amazon SageMaker
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

从 Amazon CLI 中设置默认值

您可以从 Amazon CLI 中为以下资源设置默认生命周期配置脚本:

  • 用户配置文件

  • 共享空间

下面几节概述了如何从 Amazon CLI 设置默认生命周期配置脚本。

先决条件

在开始之前,请满足以下先决条件:

创建新资源时设置默认生命周期配置

要在创建新域、用户配置文件或空间时设置默认生命周期配置,请将先前创建的生命周期配置的 ARN 作为以下 Amazon CLI 命令的一部分传递:

您必须在 KernelGateway 或 JupyterServer 默认设置中为以下值传递生命周期配置 ARN:

  • DefaultResourceSpec:LifecycleConfigArn - 这指定应用程序类型的默认生命周期配置。

  • LifecycleConfigArns - 这是附加到应用程序类型的所有生命周期配置的列表。默认生命周期配置也必须包含在此列表中。

例如,以下 API 调用使用默认生命周期配置创建一个新的用户配置文件。

aws sagemaker create-user-profile --domain-id domain-id \ --user-profile-name user-profile-name \ --region region \ --user-settings '{ "KernelGatewayAppSettings": { "DefaultResourceSpec": { "InstanceType": "ml.t3.medium", "LifecycleConfigArn": "lifecycle-configuration-arn" }, "LifecycleConfigArns": [lifecycle-configuration-arn-list] } }'

为现有资源设置默认生命周期配置

要设置或更新现有资源的默认生命周期配置,请将先前创建的生命周期配置的 ARN 作为以下 Amazon CLI 命令的一部分传递:

您必须在 KernelGateway 或 JupyterServer 默认设置中为以下值传递生命周期配置 ARN:

  • DefaultResourceSpec:LifecycleConfigArn - 这指定应用程序类型的默认生命周期配置。

  • LifecycleConfigArns - 这是附加到应用程序类型的所有生命周期配置的列表。默认生命周期配置也必须包含在此列表中。

例如,以下 API 调用使用默认生命周期配置更新用户配置文件。

aws sagemaker update-user-profile --domain-id domain-id \ --user-profile-name user-profile-name \ --region region \ --user-settings '{ "KernelGatewayAppSettings": { "DefaultResourceSpec": { "InstanceType": "ml.t3.medium", "LifecycleConfigArn": "lifecycle-configuration-arn" }, "LifecycleConfigArns": [lifecycle-configuration-arn-list] } }'

以下 API 调用可更新域以设置新的默认生命周期配置。

aws sagemaker update-domain --domain-id domain-id \ --region region \ --default-user-settings '{ "JupyterServerAppSettings": { "DefaultResourceSpec": { "InstanceType": "ml.t3.medium", "LifecycleConfigArn": "lifecycle-configuration-arn" }, "LifecycleConfigArns": [lifecycle-configuration-arn-list] } }'