Set defaults from the AWS 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.
AWS 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 AWS CLI for the following resources:
-
Domains
-
User profiles
-
Shared spaces
The following sections outline how to set default lifecycle configuration scripts from the AWS CLI.
Topics
Prerequisites
Before you begin, complete the following prerequisites:
-
Update the AWS CLI by following the steps in Installing the current AWS CLI version.
-
From your local machine, run
aws configure
and provide your AWS credentials. For information about AWS credentials, see Understanding and getting your AWS credentials. -
Onboard to SageMaker domain by following the steps in Amazon SageMaker domain overview.
-
Create a lifecycle configuration following the steps in Create and associate a lifecycle configuration.
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 AWS 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-nameuser-profile-name
\ --regionregion
\ --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 AWS 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-nameuser-profile-name
\ --regionregion
\ --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
\ --regionregion
\ --default-user-settings '{ "JupyterServerAppSettings": { "DefaultResourceSpec": { "InstanceType": "system", "LifecycleConfigArn": "lifecycle-configuration-arn
" }, "LifecycleConfigArns": [lifecycle-configuration-arn-list
] } }'