Delete an Amazon SageMaker Domain - Amazon SageMaker

Delete an Amazon SageMaker Domain

A Domain consists of a list of authorized users, configuration settings, and an Amazon Elastic File System (Amazon EFS) volume. The Amazon EFS volume contains data for the users, including notebooks, resources, and artifacts. A user can have multiple applications (apps) which support the reading and execution experience of the user’s notebooks, terminals, and consoles.

You can delete your Domain using one of the following:

  • AWS console

  • AWS Command Line Interface (AWS CLI)

  • SageMaker SDK

The following sections explain how to delete a Domain and the requirements for doing so.

Requirements

You must satisfy the following requirements to delete a Domain.

  • You must have admin permission to delete a Domain.

  • You can only delete an app with the status InService displayed as Ready in the Domain. To delete the containing Domain, you don't need to delete an app whose status is Failed. In the Domain, an attempt to delete an app in the failed state results in an error.

  • To delete a Domain, the Domain cannot contain any user profiles or shared spaces. To delete a user profile or shared space, the user profile or space cannot contain any non-failed apps.

    When you delete these resources, the following occurs:

    • App – The data (files and notebooks) in a user's home directory is saved. Unsaved notebook data is lost.

    • User profile – The user can no longer sign in to the Domain. The user loses access to their home directory, but the data is not deleted. An admin can retrieve the data from the Amazon EFS volume where it is stored under the user's AWS account.

  • To switch authentication modes from IAM to IAM Identity Center, you must delete the Domain.

EFS files

Your files are kept in an Amazon EFS volume as a backup. This backup includes the files in the mounted directory, which is /home/sagemaker-user for Amazon SageMaker Studio Classic and /root for kernels.

When you delete files from these mounted directories, the kernel or app may move the deleted files into a hidden trash folder. If the trash folder is inside the mounted directory, those files are copied into the Amazon EFS volume and will incur charges. To avoid these Amazon EFS charges, you must identify and clean the trash folder location. The trash folder location for default apps and kernels is ~/.local/. This may vary depending on the Linux distribution used for custom apps or kernels. For more information about the Amazon EFS volume, see Manage Your Amazon EFS Storage Volume in SageMaker Studio Classic.

When you use the SageMaker console to delete the Domain, the Amazon EFS volume is detached but not deleted. The same behavior occurs by default when you use the AWS CLI or the SageMaker Python SDK to delete the Domain. However, when you use the AWS CLI or the SageMaker Python SDK, you can set the RetentionPolicy to HomeEfsFileSystem=Delete to delete the Amazon EFS volume along with the Domain.

Delete an Amazon SageMaker Domain (console)

To delete a Domain
  1. Open the SageMaker console.

  2. On the left navigation pane, choose Admin configurations.

  3. Under Admin configurations, choose Domains.

  4. Select the Domain that you want to delete.

  5. Repeat the following steps for each user in the User profiles list.

    1. Choose the user.

    2. On the User Details page, for each non-failed app in the Apps list, choose Action.

    3. From the dropdown list, choose Delete.

    4. On the Delete app dialog box, choose Yes, delete app. Then enter delete in the confirmation field, and choose Delete.

    5. When Status shows as Deleted for all apps, choose Edit.

    6. On the Edit User page, choose Delete user.

    7. On the Delete user dialog box, choose Yes, delete user. Then enter delete in the confirmation field, and choose Delete.

    Important

    When a user is deleted, they lose access to the Amazon EFS volume that contains their data, including notebooks and other artifacts. The data is not deleted and can be accessed by an administrator.

  6. When all users are deleted, choose the Space management tab.

  7. Repeat the following steps for each shared space in the Spaces list.

    1. Select the name of the shared space.

    2. Choose Delete app for every app.

    3. On the Delete app dialog box, choose Yes, delete app. Then enter delete in the confirmation field, and choose Delete.

    4. Choose Cancel.

    5. Select the shared space.

    6. Choose Delete.

    7. On the Delete space dialog box, choose Yes, delete space. Then enter delete in the confirmation field, and choose Delete space.

  8. When all users and shared spaces are deleted, choose the Domain settings tab.

  9. Choose Edit.

  10. On the General settings page, choose Delete Domain.

  11. On the Delete Domain dialog box, choose Yes, delete Domain. Then enter delete in the confirmation field, and choose Delete.

Delete an Amazon SageMaker Domain (AWS CLI)

To delete a Domain
  1. Retrieve the list of Domains in your account.

    aws --region Region sagemaker list-domains
  2. Retrieve the list of applications for the Domain to be deleted.

    aws --region Region sagemaker list-apps \ --domain-id-equals DomainId
  3. Delete each application in the list.

    aws --region Region sagemaker delete-app \ --domain-id DomainId \ --app-name AppName \ --app-type AppType \ --user-profile-name UserProfileName
  4. Retrieve the list of user profiles in the Domain.

    aws --region Region sagemaker list-user-profiles \ --domain-id-equals DomainId
  5. Delete each user profile in the list.

    aws --region Region sagemaker delete-user-profile \ --domain-id DomainId \ --user-profile-name UserProfileName
  6. Retrieve the list of shared spaces in the Domain.

    aws --region Region sagemaker list-spaces \ --domain-id DomainId
  7. Delete each shared space in the list.

    aws --region Region sagemaker delete-space \ --domain-id DomainId \ --space-name SpaceName
  8. Delete the Domain. To also delete the Amazon EFS volume, specify HomeEfsFileSystem=Delete.

    aws --region Region sagemaker delete-domain \ --domain-id DomainId \ --retention-policy HomeEfsFileSystem=Retain