Set defaults from the Amazon CLI - Amazon SageMaker
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Set defaults from the Amazon CLI

Important

Custom IAM policies that allow Amazon SageMaker Studio or Amazon SageMaker Studio Classic to create Amazon SageMaker resources must also grant permissions to add tags to those resources. The permission to add tags to resources is required because Studio and Studio Classic automatically tag any resources they create. If an IAM policy allows Studio and Studio Classic to create resources but does not allow tagging, "AccessDenied" errors can occur when trying to create resources. For more information, see Provide Permissions for Tagging SageMaker Resources.

Amazon Managed Policies for Amazon SageMaker that give permissions to create SageMaker resources already include permissions to add tags while creating those resources.

Important

As of November 30, 2023, the previous Amazon SageMaker Studio experience is now named Amazon SageMaker Studio Classic. The following section is specific to using the Studio Classic application. For information about using the updated Studio experience, see Amazon SageMaker Studio.

You can set default lifecycle configuration scripts from the Amazon CLI for the following resources:

  • Domains

  • User profiles

  • Shared spaces

The following sections outline how to set default lifecycle configuration scripts from the Amazon CLI.

Prerequisites

Before you begin, complete the following prerequisites:

Set a default lifecycle configuration when creating a new resource

To set a default lifecycle configuration when creating a new domain, user profile, or space, pass the ARN of your previously created lifecycle configuration as part of one of the following Amazon CLI commands:

You must pass the lifecycle configuration ARN for the following values in the KernelGateway or JupyterServer default settings:

  • DefaultResourceSpec:LifecycleConfigArn - This specifies the default lifecycle configuration for the application type.

  • LifecycleConfigArns - This is the list of all lifecycle configurations attached to the application type. The default lifecycle configuration must also be part of this list.

For example, the following API call creates a new user profile with a default lifecycle configuration.

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] } }'

Set a default lifecycle configuration for an existing resource

To set or update the default lifecycle configuration for an existing resource, pass the ARN of your previously created lifecycle configuration as part of one of the following Amazon CLI commands:

You must pass the lifecycle configuration ARN for the following values in the KernelGateway or JupyterServer default settings:

  • DefaultResourceSpec:LifecycleConfigArn - This specifies the default lifecycle configuration for the application type.

  • LifecycleConfigArns - This is the list of all lifecycle configurations attached to the application type. The default lifecycle configuration must also be part of this list.

For example, the following API call updates a user profile with a default lifecycle configuration.

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] } }'

The following API call updates a domain to set a new default lifecycle configuration.

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] } }'