How to Delete a SageMaker Domain

One of the key features of SageMaker is the ability to create a domain, which is a collection of resources that can be used to manage your machine learning projects. However, there may come a time when you need to delete a SageMaker domain. In this blog post, we will walk you through the steps to delete a SageMaker domain.

Amazon SageMaker is a powerful machine learning platform that allows data scientists to build, train, and deploy machine learning models. One of the key features of SageMaker is the ability to create a domain, which is a collection of resources that can be used to manage your machine learning projects. However, there may come a time when you need to delete a SageMaker domain. In this blog post, we will walk you through the steps to delete a SageMaker domain.

CTA

Table of Contents

  1. Requirements
  2. Why Delete a SageMaker Domain?
  3. Steps to Delete a SageMaker Domain using Console
  4. Steps to Delete a SageMaker Domain using CLI
  5. Conclusion

Requirements

To initiate the deletion of a Domain, the following conditions must be met:

  1. Administrative Permissions:

    • You must possess administrative permissions to perform the deletion of a Domain.
  2. App Status:

    • Only apps with the status “InService” displayed as “Ready” in the Domain are eligible for deletion.
    • It’s important to note that deleting the containing Domain does not require the deletion of an app with a “Failed” status. Attempting to delete a failed app within the Domain will result in an error.
  3. User Profiles and Shared Spaces:

    • The Domain targeted for deletion must not contain any user profiles or shared spaces.
    • Similarly, for the deletion of a user profile or shared space, the associated profile or space must not contain any non-failed apps.

Upon the deletion of these resources, the following consequences occur:

  • App:

    • The data, including files and notebooks, in a user’s home directory is preserved.
    • Unsaved notebook data is lost.
  • User Profile:

    • The user loses the ability to sign in to the Domain.
    • Access to their home directory is revoked, although the data itself is not deleted.
    • An administrator has the option to retrieve the data from the Amazon EFS volume stored under the user’s AWS account.

Furthermore, if there is a need to switch authentication modes from IAM to IAM Identity Center, it is imperative to delete the Domain as part of the process.

Why Delete a SageMaker Domain?

There are several reasons why you may need to delete a SageMaker domain. For example, you may have created a domain for a project that is no longer active, or you may have created a domain with the wrong settings. Deleting a domain can also help you save costs by removing resources that are no longer needed.

Steps to Delete a SageMaker Domain using Console

Deleting a SageMaker domain is a straightforward process that can be completed in a few simple steps. Follow these steps to delete a SageMaker domain:

Step 1: Access the SageMaker Console

The first step is to access the SageMaker console. To do this, log in to your AWS account and navigate to the SageMaker console.

Alt text

Step 2: Select the Domain to Delete

Once you are in the SageMaker console, under Admin configurations, choose Domains. Then, select the domain that you want to delete from the list of domains. If you have a large number of domains, you can use the search bar to find the domain that you want to delete.

Step 3: Click on the “Delete” Button

After you have selected the domain that you want to delete, click on the “Delete” button. This will open a dialog box that will ask you to confirm that you want to delete the domain.

CTA

Step 4: Confirm the Deletion

In the dialog box, you will be asked to confirm that you want to delete the domain. Before you confirm the deletion, make sure that you have backed up any data or resources that you want to keep. Once you have confirmed the deletion, the domain and all of its resources will be permanently deleted.

Steps to Delete a SageMaker Domain using CLI

Step 1: Retrieve the list of Domains in your account.

aws --region Region sagemaker list-domains

Step 2: Retrieve the list of applications for the Domain to be deleted.

aws --region Region sagemaker list-apps \
    --domain-id-equals DomainId

Step 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

Step 4: Retrieve the list of user profiles in the Domain.

aws --region Region sagemaker list-user-profiles \
    --domain-id-equals DomainId

Step 5: Delete each user profile in the list.

aws --region Region sagemaker delete-user-profile \
    --domain-id DomainId \
    --user-profile-name UserProfileName

Step 6: Retrieve the list of shared spaces in the Domain.

aws --region Region sagemaker list-spaces \
    --domain-id DomainId

Step 7: Delete each shared space in the list.

aws --region Region sagemaker delete-space \
    --domain-id DomainId \
    --space-name SpaceName

Step 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

CTA

Conclusion

Deleting a SageMaker domain is a simple process that can be completed in just a few steps. However, it is important to make sure that you have backed up any data or resources that you want to keep before you delete the domain. By following the steps outlined in this blog post, you can safely and easily delete a SageMaker domain.


About Saturn Cloud

Saturn Cloud is your all-in-one solution for data science & ML development, deployment, and data pipelines in the cloud. Spin up a notebook with 4TB of RAM, add a GPU, connect to a distributed cluster of workers, and more. Join today and get 150 hours of free compute per month.