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

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

从中设置默认值 Amazon CLI

重要

允许 Amazon SageMaker Studio 或 Amazon SageMaker Studio Classic 创建亚马逊 SageMaker资源的自定义 IAM 策略还必须授予向这些资源添加标签的权限。需要向资源添加标签的权限,因为 Studio 和 Studio Classic 会自动标记他们创建的任何资源。如果 IAM 策略允许 Studio 和 Studio Classic 创建资源但不允许标记,则在尝试创建资源时可能会出现 AccessDenied “” 错误。有关更多信息,请参阅 提供为资源添加标签 SageMaker的权限

Amazon 适用于亚马逊的托管政策 SageMaker授予创建 SageMaker 资源的权限已经包括在创建这些资源时添加标签的权限。

重要

截至 2023 年 11 月 30 日,之前的亚马逊 SageMaker Studio 体验现在被命名为 Amazon St SageMaker udio Classic。以下部分专门介绍如何使用 Studio Classic 应用程序。有关使用更新后的 Studio 体验的信息,请参阅亚马逊 SageMaker Studio

您可以从中 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] } }'