隔離網域資源 - Amazon SageMaker AI

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

隔離網域資源

重要

允許 Amazon SageMaker Studio 或 Amazon SageMaker Studio Classic 建立 Amazon SageMaker 資源的自訂 IAM 政策也必須授與許可,才能將標籤新增至這些資源。需要將標籤新增至資源的許可,因為 Studio 和 Studio Classic 會自動標記它們建立的任何資源。如果 IAM 政策允許 Studio 和 Studio Classic 建立資源,但不允許標記,則在嘗試建立資源時可能會發生 "AccessDenied" 錯誤。如需詳細資訊,請參閱提供標記 SageMaker AI 資源的許可

提供許可來建立 SageMaker 資源的 AWS Amazon SageMaker AI 的 受管政策 已包含建立這些資源時新增標籤的許可。

您可以使用 AWS Identity and Access Management (IAM) 政策,在帳戶中 AWS 區域 的每個網域之間隔離資源。隔離的資源將再也不能從其他網域存取。在本主題中,我們將討論 IAM 政策所需的條件,以及如何套用這些條件。

可由此政策隔離的資源是具有條件金鑰 (其中包含 aws:ResourceTag/${TagKey}sagemaker:ResourceTag/${TagKey}) 的資源類型。如需 SageMaker AI 資源和相關聯條件金鑰的參考,請參閱 Amazon SageMaker AI 的動作、資源和條件金鑰

警告

包含上述條件金鑰 (因此為使用資源類型的動作) 的資源類型受此資源隔離政策影響。例如,pipeline-execution 資源類型包含上述條件金鑰,且受此政策影響。因此,以下是具有 pipeline-execution 資源類型的一些動作,支援進行資源隔離:

  • DescribePipelineExecution

  • StopPipelineExecution

  • UpdatePipelineExecution

  • RetryPipelineExecution

  • DescribePipelineDefinitionForExecution

  • ListPipelineExecutionSteps

  • SendPipelineExecutionStepSuccess

  • SendPipelineExecutionStepFailure

下列主題說明如何建立新的 IAM 政策,將網域中資源的存取限制為具有網域標籤的使用者設定檔,以及如何將此政策附加至網域的 IAM 執行角色。您必須針對帳戶中的每個網域重複此程序。如需網域標籤和回填這些標籤的詳細資訊,請參閱多個網域概觀

主控台

下列章節說明如何建立新的 IAM 政策,將網域中資源的存取限制為具有網域標籤的使用者設定檔,以及如何從 Amazon SageMaker AI 主控台將此政策附加至網域的 IAM 執行角色。

注意

此政策僅適用於使用 Amazon SageMaker Studio Classic 作為預設體驗的網域。

  1. 透過完成建立 IAM 政策 (主控台)中的步驟,並藉由以下 JSON 政策文件,建立 IAM 政策並命名為 StudioDomainResourceIsolationPolicy-domain-id

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Sid": "CreateAPIs", "Effect": "Allow", "Action": "sagemaker:Create*", "NotResource": [ "arn:aws:sagemaker:*:*:domain/*", "arn:aws:sagemaker:*:*:user-profile/*", "arn:aws:sagemaker:*:*:space/*" ] }, { "Sid": "ResourceAccessRequireDomainTag", "Effect": "Allow", "Action": [ "sagemaker:Update*", "sagemaker:Delete*", "sagemaker:Describe*" ], "Resource": "*", "Condition": { "StringEquals": { "aws:ResourceTag/sagemaker:domain-arn": "domain-arn" } } }, { "Sid": "AllowActionsThatDontSupportTagging", "Effect": "Allow", "Action": [ "sagemaker:DescribeImageVersion", "sagemaker:UpdateImageVersion", "sagemaker:DeleteImageVersion", "sagemaker:DescribeModelCardExportJob", "sagemaker:DescribeAction" ], "Resource": "*" }, { "Sid": "DeleteDefaultApp", "Effect": "Allow", "Action": "sagemaker:DeleteApp", "Resource": "arn:aws:sagemaker:*:*:app/domain-id/*/jupyterserver/default" } ] }
  2. 完成修改角色 (主控台) 中的步驟,將 StudioDomainResourceIsolationPolicy-domain-id 政策附加至網域的執行角色。

AWS CLI

下列章節說明如何建立新的 IAM 政策,將網域中資源的存取限制為具有網域標籤的使用者設定檔,以及如何從 AWS CLI將此政策附加至網域的 IAM 執行角色。

注意

此政策僅適用於使用 Amazon SageMaker Studio Classic 作為預設體驗的網域。

  1. 從您的本機機器,藉由以下內容,建立一個檔案且檔名為 StudioDomainResourceIsolationPolicy-domain-id

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Sid": "CreateAPIs", "Effect": "Allow", "Action": "sagemaker:Create*", "NotResource": [ "arn:aws:sagemaker:*:*:domain/*", "arn:aws:sagemaker:*:*:user-profile/*", "arn:aws:sagemaker:*:*:space/*" ] }, { "Sid": "ResourceAccessRequireDomainTag", "Effect": "Allow", "Action": [ "sagemaker:Update*", "sagemaker:Delete*", "sagemaker:Describe*" ], "Resource": "*", "Condition": { "StringEquals": { "aws:ResourceTag/sagemaker:domain-arn": "domain-arn" } } }, { "Sid": "AllowActionsThatDontSupportTagging", "Effect": "Allow", "Action": [ "sagemaker:DescribeImageVersion", "sagemaker:UpdateImageVersion", "sagemaker:DeleteImageVersion", "sagemaker:DescribeModelCardExportJob", "sagemaker:DescribeAction" ], "Resource": "*" }, { "Sid": "DeleteDefaultApp", "Effect": "Allow", "Action": "sagemaker:DeleteApp", "Resource": "arn:aws:sagemaker:*:*:app/domain-id/*/jupyterserver/default" } ] }
  2. 使用 StudioDomainResourceIsolationPolicy-domain-id 檔案,建立新的 IAM 政策。

    aws iam create-policy --policy-name StudioDomainResourceIsolationPolicy-domain-id --policy-document file://StudioDomainResourceIsolationPolicy-domain-id
  3. 將新建立的政策附加至作為網域執行角色使用的新角色或現有角色。

    aws iam attach-role-policy --policy-arn arn:aws:iam:account-id:policy/StudioDomainResourceIsolationPolicy-domain-id --role-name domain-execution-role