Code Editor lifecycle configurations - Amazon SageMaker

Code Editor lifecycle configurations

You can use Code Editor lifecycle configurations to automate customization for your Studio environment. This customization includes installing custom packages, configuring extensions, preloading datasets, and setting up source code repositories.

The following instructions use the AWS Command Line Interface (AWS CLI) to create, attach, debug, and detach lifecycle configurations for the CodeEditor application type:

Create and attach lifecycle configurations in Studio

The following section provides AWS CLI commands to create a lifecycle configuration, attach a lifecycle configuration when creating a new user profile, and attach a lifecycle configuration when updating a user profile. For prerequisites and general steps on creating and attaching lifecycle configurations in Studio, see Create and associate a lifecycle configuration.

When creating your Studio lifecycle configuration with the create-studio-lifecycle-config command, be sure to specify that the studio-lifecycle-config-app-type is CodeEditor. The following example shows how to create a new Studio lifecycle configuration for your Code Editor application.

aws sagemaker create-studio-lifecycle-config \ --studio-lifecycle-config-name my-code-editor-lcc \ --studio-lifecycle-config-content $LCC_CONTENT \ --studio-lifecycle-config-app-type CodeEditor

Note the ARN of the newly created lifecycle configuration that is returned. When attaching a lifecycle configuration, provide this ARN within the LifecycleConfigArns list of CodeEditorAppSettings.

You can attach a lifecycle configuration when creating a user profile or domain. The following example shows how to create a new user profile with the lifecycle configuration attached. You can also create a new domain with a lifecycle configuration attached by using the create-domain command.

# Create a new UserProfile aws sagemaker create-user-profile \ --domain-id domain-id \ --user-profile-name user-profile-name \ --user-settings '{ "CodeEditorAppSettings": { "LifecycleConfigArns": [lifecycle-configuration-arn-list] } }'

You can alternatively attach a lifecycle configuration when updating a user profile or domain. The following example shows how to update a user profile with the lifecycle configuration attached. You can also update a new domain with a lifecycle configuration attached by using the update-domain command.

# Update a UserProfile aws sagemaker update-user-profile \ --domain-id domain-id \ --user-profile-name user-profile-name \ --user-settings '{ "CodeEditorAppSettings": { "LifecycleConfigArns": [lifecycle-configuration-arn-list] } }'

Debug lifecycle configurations in Studio

For instructions on debugging lifecycle configurations in Studio, see Debug lifecycle configurations.

To find the logs for a specific application, search the log streams using the following format:

domain-id/space-name/CodeEditor/default/LifecycleConfigOnStart

Detach lifecycle configurations in Studio

For steps on detaching lifecycle configurations in Studio, see Detach lifecycle configurations.

To detach a lifecycle configuration using the AWS CLI, remove the desired lifecycle configuration from the list of lifecycle configurations attached to the resource. Then pass the list as part of the respective command:

For example, the following command removes all lifecycle configurations for the Code Editor application attached to the domain.

aws sagemaker update-domain --domain-id domain-id \ --default-user-settings '{ "CodeEditorAppSettings": { "LifecycleConfigArns": [] } }'