

# Collaboration with shared spaces
<a name="domain-space"></a>

An Amazon SageMaker Studio Classic shared space consists of a shared JupyterServer application and a shared directory. A JupyterLab shared space consists of a shared JupyterLab application and a shared directory within Amazon SageMaker Studio. All user profiles in a domain have access to all shared spaces in the domain. Amazon SageMaker AI automatically scopes resources in a shared space within the context of the Amazon SageMaker Studio Classic application that you launch in that shared space. Resources in a shared space include notebooks, files, experiments, and models. Use shared spaces to collaborate with other users in real-time using features like automatic tagging, real time co-editing of notebooks, and customization. 

Shared spaces are available in:
+ Amazon SageMaker Studio Classic
+ JupyterLab

A Studio Classic shared space only supports Studio Classic and KernelGateway applications. A shared space only supports the use of a JupyterLab 3 image Amazon Resource Name (ARN). For more information, see [JupyterLab Versioning in Amazon SageMaker Studio Classic](studio-jl.md).

 Amazon SageMaker AI automatically tags all SageMaker AI resources that you create within the scope of a shared space. You can use these tags to monitor costs and plan budgets using tools, such as AWS Budgets. 

A shared space uses the same VPC settings as the domain that it's created in. 

**Note**  
 Shared spaces do not support the use of Amazon SageMaker Data Wrangler or Amazon EMR cross-account clusters. 

 **Automatic tagging** 

 All resources created in a shared space are automatically tagged with a domain ARN tag and shared space ARN tag. The domain ARN tag is based on the domain ID, while the shared space ARN tag is based on the shared space name. 

 You can use these tags to monitor AWS CloudTrail usage. For more information, see [Log Amazon SageMaker API Calls with AWS CloudTrail](https://docs.aws.amazon.com//sagemaker/latest/dg/logging-using-cloudtrail.html). 

 You can also use these tags to monitor costs with AWS Billing and Cost Management. For more information, see [Using AWS cost allocation tags](https://docs.aws.amazon.com//awsaccountbilling/latest/aboutv2/cost-alloc-tags.html). 

 **Real time co-editing of notebooks** 

 A key benefit of a shared space is that it facilitates collaboration between members of the shared space in real time. Users collaborating in a workspace get access to a shared Studio Classic application where they can access, read, and edit their notebooks in real time. Real time collaboration is only supported for JupyterServer applications within a shared space. 

 Users with access to a shared space can simultaneously open, view, edit, and execute Jupyter notebooks in the shared Studio Classic or JupyterLab application in that space. 

The notebook indicates each co-editing user with a different cursor that shows the user profile name. While multiple users can view the same notebook, co-editing is best suited for small groups of two to five users.

To track changes being made by multiple users, we strongly recommended using Studio Classic's built-in Git-based version control.

 **JupyterServer 2** 

To use shared spaces in Studio Classic, Jupyter Server version 2 is required. Certain JupyterLab extensions and packages can forcefully downgrade Jupyter Server to version 1. This prevents the use of shared space. Run the following from the command prompt to change the version number and continue using shared spaces.

```
conda activate studio
pip install jupyter-server==2.0.0rc3
```

 **Customize a shared space** 

To attach a lifecycle configuration or custom image to a shared space, you must use the AWS CLI. For more information about creating and attaching lifecycle configurations, see [Create and Associate a Lifecycle Configuration with Amazon SageMaker Studio Classic](studio-lcc-create.md). For more information about creating and attaching custom images, see [Custom Images in Amazon SageMaker Studio Classic](studio-byoi.md).

# Create a shared space
<a name="domain-space-create"></a>

**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 AI resources](security_iam_id-based-policy-examples.md#grant-tagging-permissions).  
[AWS managed policies for Amazon SageMaker AI](security-iam-awsmanpol.md) that give permissions to create SageMaker resources already include permissions to add tags while creating those resources.

 The following topic demonstrates how to create a shared space in an existing Amazon SageMaker AI domain. If you created your domain without support for shared spaces, you must add support for shared spaces to your existing domain before you can create a shared space. 

**Topics**
+ [Add shared space support to an existing domain](#domain-space-add)
+ [Create a shared space](#domain-space-create-app)

## Add shared space support to an existing domain
<a name="domain-space-add"></a>

 You can use the SageMaker AI console or the AWS CLI to add support for shared spaces to an existing domain. If the domain is using `VPC only` network access, then you can only add shared space support using the AWS CLI.

### Console
<a name="domain-space-add-console"></a>

 Complete the following procedure to add support for Studio Classic shared spaces to an existing domain from the SageMaker AI console. 

1. Open the Amazon SageMaker AI console at [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/).

1. On the left navigation pane, choose **Admin configurations**.

1. Under **Admin configurations**, choose **domains**. 

1.  From the list of domains, select the domain that you want to open the **domain settings** page for. 

1.  On the **domain details** page, choose the **domain settings** tab. 

1.  Choose **Edit**. 

1.  For **Space default execution role**, set an IAM role that is used by default for all shared spaces created in the domain. 

1.  Choose **Next**. 

1.  Choose **Next**. 

1.  Choose **Next**. 

1.  Choose **Submit**. 

### AWS CLI
<a name="domain-space-add-cli"></a>

------
#### [ Studio Classic ]

Run the following command from the terminal of your local machine to add default shared space settings to a domain from the AWS CLI. If you are adding default shared space settings to a domain within an Amazon VPC, you must also include a list of security groups. Studio Classic shared spaces only support the use of JupyterLab 3 image ARNs. For more information, see [JupyterLab Versioning in Amazon SageMaker Studio Classic](studio-jl.md).

```
# Public Internet domain
aws --region region \
sagemaker update-domain \
--domain-id domain-id \
--default-space-settings "ExecutionRole=execution-role-arn,JupyterServerAppSettings={DefaultResourceSpec={InstanceType=example-instance-type,SageMakerImageArn=sagemaker-image-arn}}"

# VPCOnly domain
aws --region region \
sagemaker update-domain \
--domain-id domain-id \
--default-space-settings "ExecutionRole=execution-role-arn,JupyterServerAppSettings={DefaultResourceSpec={InstanceType=system,SageMakerImageArn=sagemaker-image-arn}},SecurityGroups=[security-groups]"
```

Use the following command to verify that the default shared space settings have been updated. 

```
aws --region region \
sagemaker describe-domain \
--domain-id domain-id
```

------
#### [ JupyterLab ]

Run the following command from the terminal of your local machine to add default shared space settings to a domain from the AWS CLI. If you are adding default shared space settings to a domain within an Amazon VPC, you must also include a list of security groups. Studio Classic shared spaces only support the use of JupyterLab 4 image ARNs. For more information, see [JupyterLab Versioning in Amazon SageMaker Studio Classic](studio-jl.md).

```
# Public Internet domain
aws --region region \
sagemaker update-domain \
--domain-id domain-id \
--default-space-settings "ExecutionRole=execution-role-arn", JupyterLabAppSettings={DefaultResourceSpec={InstanceType=example-instance-type,SageMakerImageArn=sagemaker-image-arn}}"

# VPCOnly domain
aws --region region \
sagemaker update-domain \
--domain-id domain-id \
--default-space-settings "ExecutionRole=execution-role-arn, SecurityGroups=[security-groups]"
```

Use the following command to verify that the default shared space settings have been updated. 

```
aws --region region \
sagemaker describe-domain \
--domain-id domain-id
```

------

## Create a shared space
<a name="domain-space-create-app"></a>

The following sections demonstrate how to create a shared space from the Amazon SageMaker AI console, Amazon SageMaker Studio, or the AWS CLI.

### Create from Studio
<a name="domain-space-create-updated"></a>

Use the following procedures to create a shared space in a domain from Studio.

------
#### [ Studio Classic ]

1. Navigate to Studio following the steps in [Launch Amazon SageMaker Studio](studio-updated-launch.md).

1. From the Studio UI, find the applications pane on the left side.

1. From the applications pane, select **Studio Classic**.

1. Choose **Create Studio Classic space**

1. In the pop up window, enter a name for the space.

1. Choose **Create space**.

------
#### [ JupyterLab ]

1. Navigate to Studio following the steps in [Launch Amazon SageMaker Studio](studio-updated-launch.md).

1. From the Studio UI, find the applications pane on the left side.

1. From the applications pane, select **JupyterLab**.

1. Choose **Create JupyterLab space**

1. In the pop up window, enter a name for the space.

1. Choose **Create space**.

------

### Create from the console
<a name="domain-space-create-console"></a>

 Complete the following procedure to create a shared space in a domain from the SageMaker AI console. 

1. Open the Amazon SageMaker AI console at [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/).

1. On the left navigation pane, choose **Admin configurations**.

1. Under **Admin configurations**, choose **domains**. 

1.  From the list of domains, select the domain that you want to create a shared space for. 

1.  On the **domain details** page, choose the **Space management** tab. 

1.  Choose **Create**. 

1.  Enter a name for your shared space. shared space names within a domain must be unique. The execution role for the shared space is set to the domain IAM execution role. 

### Create from AWS CLI
<a name="domain-space-create-cli"></a>

This section shows how to create a shared space from the AWS CLI. 

You cannot set the execution role of a shared space when creating or updating it. The `DefaultDomainExecRole` can only be set when creating or updating the domain. shared spaces only support the use of JupyterLab 3 image ARNs. For more information, see [JupyterLab Versioning in Amazon SageMaker Studio Classic](studio-jl.md).

To create a shared space from the AWS CLI, run one of the following commands from the terminal of your local machine.

------
#### [ Studio Classic ]

```
aws --region region \
sagemaker create-space \
--domain-id domain-id \
--space-name space-name \
--space-settings '{
  "JupyterServerAppSettings": {
    "DefaultResourceSpec": {
      "SageMakerImageArn": "sagemaker-image-arn",
      "InstanceType": "system"
    }
  }
}'
```

------
#### [ JupyterLab ]

```
aws --region region \
sagemaker create-space \
--domain-id domain-id \
--space-name space-name \
--ownership-settings "{\"OwnerUserProfileName\": \"user-profile-name\"}" \
--space-sharing-settings "{\"SharingType\": \"Shared\"}" \
--space-settings "{\"AppType\": \"JupyterLab\"}"
```

------

# Get information about shared spaces
<a name="domain-space-list"></a>

**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](studio-updated.md).  
Studio Classic is still maintained for existing workloads but is no longer available for onboarding. You can only stop or delete existing Studio Classic applications and cannot create new ones. We recommend that you [migrate your workload to the new Studio experience](studio-updated-migrate.md).

 This guide shows how to access a list of shared spaces in an Amazon SageMaker AI domain with the Amazon SageMaker AI console, Amazon SageMaker Studio, or the AWS CLI. It also shows how to view details of a shared space from the AWS CLI. 

**Topics**
+ [List shared spaces](#domain-space-list-spaces)
+ [View shared space details](#domain-space-describe)

## List shared spaces
<a name="domain-space-list-spaces"></a>

 The following topic describes how to view a list of shared spaces within a domain from the SageMaker AI console or the AWS CLI. 

### List shared spaces from Studio
<a name="domain-space-list-updated"></a>

 Complete the following procedure to view a list of the shared spaces in a domain from Studio.

1. Navigate to Studio following the steps in [Launch Amazon SageMaker Studio](studio-updated-launch.md).

1. From the Studio UI, find the applications pane on the left side.

1. From the applications pane, select **Studio Classic** or **JupyterLab**. You can view the spaces that are being used to run the application type.

### List shared spaces from the console
<a name="domain-space-list-console"></a>

 Complete the following procedure to view a list of the shared spaces in a domain from the SageMaker AI console. 

1. Open the Amazon SageMaker AI console at [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/).

1. On the left navigation pane, choose **Admin configurations**.

1. Under **Admin configurations**, choose **domains**. 

1.  From the list of domains, select the domain that you want to view the list of shared spaces for. 

1.  On the **domain details** page, choose the **Space management** tab. 

### List shared spaces from the AWS CLI
<a name="domain-space-list-cli"></a>

 To list the shared spaces in a domain from the AWS CLI, run the following command from the terminal of your local machine.

```
aws --region region \
sagemaker list-spaces \
--domain-id domain-id
```

## View shared space details
<a name="domain-space-describe"></a>

 The following section describes how to view shared space details from the SageMaker AI console, Studio, or the AWS CLI. 

### View shared spaces details from Studio
<a name="domain-space-describe-updated"></a>

 Complete the following procedure to view the details of a shared spaces in a domain from Studio.

1. Navigate to Studio following the steps in [Launch Amazon SageMaker Studio](studio-updated-launch.md).

1. From the Studio UI, find the applications pane on the left side.

1. From the applications pane, select **Studio Classic** or **JupyterLab**. You can view the spaces that are running the application.

1. Select the name of the space that you want to view more details for.

### View shared space details from the console
<a name="domain-space-describe-console"></a>

 You can view the details of a shared space from the SageMaker AI console using the following procedure. 

1. Open the Amazon SageMaker AI console at [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/).

1. On the left navigation pane, choose **Admin configurations**.

1. Under **Admin configurations**, choose **domains**. 

1.  From the list of domains, select the domain that you want to view the list of shared spaces for. 

1.  On the **domain details** page, choose the **Space management** tab. 

1.  Select the name of the space to open a new page that lists details about the shared space. 

### View shared space details from the AWS CLI
<a name="domain-space-describe-cli"></a>

To view the details of a shared space from the AWS CLI, run the following command from the terminal of your local machine.

```
aws --region region \
sagemaker describe-space \
--domain-id domain-id \
--space-name space-name
```

# Edit a shared space
<a name="domain-space-edit"></a>

 You can only edit the details for an Amazon SageMaker Studio Classic or JupyterLab shared space using the AWS CLI. You can't edit the details of a shared space from the Amazon SageMaker AI console. You can only update workspace attributes when there are no running applications in the shared space. 

------
#### [ Studio Classic ]

To edit the details of a Studio Classic shared space from the AWS CLI, run the following one of the following commands from the terminal of your local machine. shared spaces only support the use of JupyterLab 3 image ARNs. For more information, see [JupyterLab Versioning in Amazon SageMaker Studio Classic](studio-jl.md).

```
aws --region region \
sagemaker update-space \
--domain-id domain-id \
--space-name space-name \
--query SpaceArn --output text \
--space-settings '{
  "JupyterServerAppSettings": {
    "DefaultResourceSpec": {
      "SageMakerImageArn": "sagemaker-image-arn",
      "InstanceType": "system"
    }
  }
}'
```

------
#### [ JupyterLab ]

To edit the details of a JupyterLab shared space from the AWS CLI, run the following one of the following commands from the terminal of your local machine. shared spaces only support the use of JupyterLab 4 image ARNs. For more information, see [SageMaker JupyterLab](studio-updated-jl.md).

```
aws --region region \
sagemaker update-space \
--domain-id domain-id \
--space-name space-name \
--space-settings "{
      "SpaceStorageSettings": {
      "EbsStorageSettings": { 
      "EbsVolumeSizeInGb":100
    }
    }
  }
}"
```

------

# Delete a shared space
<a name="domain-space-delete"></a>

**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](studio-updated.md).  
Studio Classic is still maintained for existing workloads but is no longer available for onboarding. You can only stop or delete existing Studio Classic applications and cannot create new ones. We recommend that you [migrate your workload to the new Studio experience](studio-updated-migrate.md).

 The following topic shows how to delete an Amazon SageMaker Studio Classic shared space from the Amazon SageMaker AI console or AWS CLI. A shared space can only be deleted if it has no running applications. 

**Topics**
+ [Console](#domain-space-delete-console)
+ [AWS CLI](#domain-space-delete-cli)

## Console
<a name="domain-space-delete-console"></a>

 Complete the following procedure to delete a shared space in the Amazon SageMaker AI domain from the SageMaker AI console. 

1. Open the Amazon SageMaker AI console at [https://console.aws.amazon.com/sagemaker/](https://console.aws.amazon.com/sagemaker/).

1. On the left navigation pane, choose **Admin configurations**.

1. Under **Admin configurations**, choose **domains**. 

1.  From the list of domains, select the domain that you want to create a shared space for. 

1.  On the **domain details** page, choose the **Space management** tab. 

1.  Select the shared space that you want to delete. The shared space must not contain any non-failed apps. 

1.  Choose **Delete**. This opens a new window. 

1.  Choose **Yes, delete space**. 

1.  Enter *delete* in the field. 

1.  Choose **Delete space**. 

## AWS CLI
<a name="domain-space-delete-cli"></a>

To delete a shared space from the AWS CLI, run the following command from the terminal of your local machine.

```
aws --region region \
sagemaker delete-space \
--domain-id domain-id \
--space-name space-name
```