

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 Studio 中建立和連接生命週期組態
<a name="code-editor-use-lifecycle-configurations-studio-create"></a>

下一節提供 AWS CLI 命令來建立生命週期組態、在建立新使用者設定檔時連接生命週期組態，以及在更新使用者設定檔時連接生命週期組態。如需在 Studio 中建立和連接生命週期組態的先決條件和一般步驟，請參閱[生命週期組態建立](jl-lcc-create.md)。

使用 `create-studio-lifecycle-config` 命令建立 Studio 生命週期組態時，請務必將 `studio-lifecycle-config-app-type` 指定為 `{{CodeEditor}}`。以下範例顯示如何為您的程式碼編輯器應用程式建立新的 Studio 生命週期組態。

```
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}}
```

記下傳回之新建立之生命週期組態的 ARN。連接生命週期組態時，請在 `CodeEditorAppSettings` 的 `LifecycleConfigArns` 清單內提供此 ARN。

您可以在建立使用者設定檔或網域時連接生命週期組態。以下範例示範如何建立連接生命週期組態的新使用者描述檔。您也可以使用 [create-domain](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/opensearch/create-domain.html) 命令，建立已連接生命週期組態的新網域或空間。

```
# 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}}]
  }
}'
```

或者，您也可以在更新使用者設定檔或網域時連接生命週期組態。以下範例展示如何更新已連接生命週期組態的使用者設定檔。您也可以使用 [update-domain](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sagemaker/update-domain.html) 命令，更新已連接生命週期組態的新網域。

```
# 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}}]
  }
}'
```