

# Code spaces in Identity Center domains
<a name="code-spaces-idc"></a>

In Identity Center domains, Amazon SageMaker Unified Studio provides spaces that you access from the **Spaces** tab on the **Compute** page. The available application types are JupyterLab and Code Editor. You can create multiple spaces with either application type as needed.

## Creating a code space in Identity Center domains
<a name="create-space"></a>

To create a space, complete the following steps:

1. Navigate to Amazon SageMaker Unified Studio using the URL from your admin and log in using your SSO or AWS credentials. 

1. Navigate to the project you want to create a space in. You can do this by choosing **Browse all projects** from the center menu.

1. In the **Build** menu, choose **Spaces** to navigate to the **Spaces** tab on the **Compute** page.

1. Choose **Create space**.

1. Under **Name**, enter a name for the space. This name must be unique. No spaces in the project can use the same name.

1. Under **Application**, choose the IDE application you want to use with the space.

1. Under **Instance**, choose an Amazon EC2 instance that is most compatible with your use case.
**Note**  
If you use a GPU instance type when configuring your Code Editor application, you must also use a GPU-based image. Within a space, your data is stored in an Amazon EBS volume that persists independently from the life of an instance. Your data is not lost when you change instances.

1. Under **Image**, choose the image you want to use.

1. Under **EBS space storage**, enter a value from 16 to 100 to choose a storage size.

1. (Optional) Choose the lifecycle configuration for the space.

   1. Find your domain ID. For instructions, see [Get project details](view-project-details.md).

   1. Find your user profile ID:

      1. In the **Compute** panel, choose the **Spaces** tab.

      1. The user profile ID is the string following `default-` of the default JupyterLab space.

   1. [ Create a lifecycle configuration](https://docs.aws.amazon.com/sagemaker/latest/dg/jl-lcc-create.html#jl-lcc-create-console) for Amazon SageMaker Unified Studio and reference your ID values from step b.
**Note**  
Attaching the lifecycle configuration to your Amazon SageMaker AI domain and user profile through the AWS CLI is not currently supported. Use the console to create lifecycle configurations.

   1. Under **Lifecycle configuration**, choose the lifecycle you created.

1. Under **Idle time**, enter the amount of time before the space will time out and stop running.

1. (Optional) Attach a custom file system to your space.

   All spaces created through Amazon SageMaker Unified Studio are private spaces. To make a custom Amazon EFS file system available in the **Attach custom file system** dropdown, you must register it under the default *user* settings for your domain (not the default space settings, which apply to shared spaces only).

   1. Ensure your Amazon EFS file system has mount targets in each subnet associated with your Amazon SageMaker AI domain, and that each mount target includes the domain's security group (named `security-group-for-inbound-nfs-{{domain-id}}`). For more information, see [Adding a custom file system to a domain](https://docs.aws.amazon.com/sagemaker/latest/dg/domain-custom-file-system.html).

   1. Register the file system under the default user settings by running the following AWS CLI command:

      ```
      aws sagemaker update-domain --domain-id {{domain-id}} \
      --default-user-settings '{
          "CustomFileSystemConfigs": [
              {
                  "EFSFileSystemConfig": {
                      "FileSystemId": "{{file-system-id}}",
                      "FileSystemPath": "/"
                  }
              }
          ]
      }'
      ```
**Important**  
Use `--default-user-settings` (not `--default-space-settings`). In Amazon SageMaker Unified Studio, all spaces are private spaces. File systems registered under `--default-space-settings` apply only to shared spaces and will not appear in the Amazon SageMaker Unified Studio console.

   1. Under **Attach custom file system**, choose the file system you registered.

1. Choose **Create and start space** to create the space and have it start running.

It might take up to 5 minutes for Amazon SageMaker Unified Studio to finish creating the space. After the space is created, you can view it in the list on the **Spaces** tab and choose **Open** to launch the IDE in your browser.

You can then perform various actions using the three-dot **Actions** menu on the **Spaces** tab in Amazon SageMaker Unified Studio. You can edit the space, start or stop running the application, delete the space, or view information about the space.

## Editing a code space in Identity Center domains
<a name="edit-space"></a>

Project members can edit a space at any time to change certain configurations. Before editing a space, make sure that you have saved any changes to your work in that space.

**Note**  
A space's name and IDE application cannot be changed.

To edit configurations for a space, complete the following steps:

1. Navigate to Amazon SageMaker Unified Studio using the URL from your admin and log in using your SSO or AWS credentials. 

1. Navigate to the project you want to edit a space in. You can do this by choosing **Browse all projects** from the center menu.

1. In the **Build** menu, choose **Spaces** to navigate to the **Spaces** tab on the **Compute** page.

1. Choose the three-dot **Actions** menu next to the space you want to edit. Then choose **Configure space**.

1. Make the desired changes, then choose **Save and restart** if the space is running, or **Save and start** if the space is stopped.

**Note**  
Saving changes to a running space requires a restart, and any unsaved changes will be lost.

## Deleting a code space in Identity Center domains
<a name="delete-space"></a>

Project members can choose to delete a space in Amazon SageMaker Unified Studio. Deleting a space is permanent and cannot be undone. Before deleting a space, make sure that you have saved all your data and that you are sure that this is the action you would like to take.

**Note**  
You cannot delete the default JupyterLab space in Amazon SageMaker Unified Studio.

To delete a space, complete the following steps:

1. Navigate to Amazon SageMaker Unified Studio using the URL from your admin and log in using your SSO or AWS credentials. 

1. Navigate to the project you want to delete a space in. You can do this by choosing **Browse all projects** from the center menu.

1. In the **Build** menu, choose **Spaces** to navigate to the **Spaces** tab on the **Compute** page.

1. Choose the three-dot **Actions** menu next to the space you want to delete. Then choose **Delete**.

1. Review the information in the window provided, then type **confirm** where indicated.

1. Choose **Delete this space**.

## Amazon Q support in code spaces for Identity Center domains
<a name="using-the-coding-assistant"></a>

Amazon Q free tier support is available across all code space types in IAM domains. When your administrator has subscribed to Amazon Q Developer and added it to your domain, you can access the Amazon Q chat interface and inline code suggestions in both JupyterLab and Code Editor spaces.