

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# データソースにアクセスするための IAM アクセス許可を設定する (管理者向け)
<a name="sagemaker-sql-extension-datasources-connection-permissions"></a>

管理者は、JupyterLab アプリケーションで使用される実行ロールに、設定された AWS Glue 接続を介してデータにアクセスするために必要な AWS IAM アクセス許可があることを確認する必要があります。
+ **を使用して管理者が作成した接続 AWS CLI**: [管理者が作成した](sagemaker-sql-extension-datasources-glue-connection.md) AWS Glue 接続を表示してデータにアクセスするには、管理者に Studio の JupyterLab アプリケーションで使用される SageMaker AI 実行ロールに特定のアクセス許可をアタッチしてもらう必要があります。これには AWS Glue、、Secrets Manager、およびデータベース固有のアクセス許可へのアクセスが含まれます。管理者が作成した接続は、特定の AWS Glue カタログまたはデータベースを表示するアクセス許可を付与された実行ロールを共有するすべてのアプリケーションに表示されます。データソースのタイプごとに必要なアクセス許可のリストについては、「[管理者定義の接続に必要な IAM アクセス許可](#admin-defined-connections-permissions)」の「管理者定義の接続許可」を参照してください。
+ **JupyterLab の SQL 拡張機能 UI を使用してユーザーが作成した接続**: 同じ実行ロールを共有する[ユーザープロファイルによって作成された](sagemaker-sql-extension-datasources-glue-connection-user-defined.md)接続も、その接続の表示範囲がユーザーによって作成された接続のみに限定されていない限り、一覧表示されます。ユーザーが作成した接続には、その接続を作成したユーザープロファイルのタグが付けられます。ユーザーが作成した接続を表示、更新、削除する機能を、それらを作成したユーザーのみに制限するには、管理者は実行ロールの IAM アクセス許可にタグベースのアクセスコントロール制限を追加できます。必要な追加のタグベースのアクセスコントロールについては、「[ユーザー定義の接続にに必要な IAM アクセス許可](#user-defined-connections-permissions)」を参照してください。

## 管理者定義の接続に必要な IAM アクセス許可
<a name="admin-defined-connections-permissions"></a>

Studio の JupyterLab アプリケーションで使用される SageMaker AI 実行ロールに、 AWS Glue 接続を介してデータソースへのアクセスを許可するには、次のインラインポリシーをロールにアタッチします。

各データソースまたは認証方法の特定のアクセス許可とポリシーの詳細を表示するには、以下の関連する接続タイプを選択します。

**注記**  
ポリシーのアクセス許可は、必要なリソースとアクションのみに制限することをお勧めします。  
ポリシーをスコープダウンして、最小特権のアクセスを許可するには、ポリシー内のワイルドカード `"Resource": ["*"]` を特定の ARN に置き換えて、アクセスが必要なリソースを正確に指定します。リソースへのアクセスを制御する方法の詳細については、「[きめ細かな ARN アクセス許可で AWS リソースアクセスを微調整する](#resource-access-control)」を参照してください。

### すべての接続タイプ
<a name="datasources-connection-permissions-all"></a>

**注記**  
このポリシーは、必要なアクションとリソースのみとするようにスコープダウンすることを強くお勧めします。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "GetS3AndDataSourcesMetadata",
            "Effect": "Allow",
            "Action": [
                "glue:GetDatabases",
                "glue:GetSchema",
                "glue:GetTables",
                "s3:ListBucket",
                "s3:GetObject",
                "s3:GetBucketLocation",
                "glue:GetDatabase",
                "glue:GetTable",
                "glue:ListSchemas",
                "glue:GetPartitions"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/*",
                "arn:aws:glue:{{us-east-1}}:{{111122223333}}:catalog",
    "arn:aws:glue:{{us-east-1}}:{{111122223333}}:connection/*"
            ]
        },
        {
            "Sid": "ExecuteQueries",
            "Effect": "Allow",
            "Action": [
                "athena:ListDataCatalogs",
                "athena:ListDatabases",
                "athena:ListTableMetadata",
                "athena:StartQueryExecution",
                "athena:GetQueryExecution",
                "athena:RunQuery",
                "athena:StartSession",
                "athena:GetQueryResults",
                "athena:ListWorkGroups",
                "s3:ListMultipartUploadParts",
                "s3:ListBucket",
                "s3:GetBucketLocation",
                "athena:GetDataCatalog",
                "s3:AbortMultipartUpload",
                "s3:GetObject",
                "s3:PutObject",
                "athena:GetWorkGroup"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/*",
                "arn:aws:athena:{{us-east-1}}:{{111122223333}}:workgroup/{{workgroup-name}}"
            ]
        },
        {
            "Sid": "GetGlueConnections",
            "Effect": "Allow",
            "Action": [
                "glue:GetConnections",
                "glue:GetConnection"
            ],
            "Resource": [
                "arn:aws:glue:{{us-east-1}}:{{111122223333}}:catalog",
                "arn:aws:glue:{{us-east-1}}:{{111122223333}}:connection/*"
            ]
        },
        {
            "Sid": "GetSecrets",
            "Effect": "Allow",
            "Action": [
                "secretsmanager:GetSecretValue"
            ],
            "Resource": [
                "arn:aws:secretsmanager:{{us-east-1}}:{{111122223333}}:{{secret:secret-name}}"
            ]
        },
        {
            "Sid": "GetClusterCredentials",
            "Effect": "Allow",
            "Action": [
                "redshift:GetClusterCredentials"
            ],
            "Resource": [
                "arn:aws:redshift:{{us-east-1}}:{{111122223333}}:cluster:{{cluster-name}}"
            ]
        }
    ]
}
```

------

### Athena
<a name="datasources-connection-permissions-athena"></a>

**注記**  
このポリシーは、必要なリソースのみとするようにスコープダウンすることを強くお勧めします。

詳細については、「[Athena ドキュメント](https://docs.aws.amazon.com/athena/latest/ug/federated-query-iam-access.html)」の「*IAM アクセス許可ポリシーの例*」を参照してください。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "GetS3AndDataSourcesMetadata",
            "Effect": "Allow",
            "Action": [
                "glue:GetDatabases",
                "glue:GetSchema",
                "glue:GetTables",
                "s3:ListBucket",
                "s3:GetObject",
                "s3:GetBucketLocation",
                "glue:GetDatabase",
                "glue:GetTable",
                "glue:ListSchemas",
                "glue:GetPartitions"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/*",                
                "arn:aws:glue:{{us-east-2}}:{{111122223333}}:catalog",
                "arn:aws:glue:{{us-east-2}}:{{111122223333}}:connection/*"
            ]
        },
        {
            "Sid": "ExecuteAthenaQueries",
            "Effect": "Allow",
            "Action": [
                "athena:ListDataCatalogs",
                "athena:ListDatabases",
                "athena:ListTableMetadata",
                "athena:StartQueryExecution",
                "athena:GetQueryExecution",
                "athena:RunQuery",
                "athena:StartSession",
                "athena:GetQueryResults",
                "athena:ListWorkGroups",
                "s3:ListMultipartUploadParts",
                "s3:ListBucket",
                "s3:GetBucketLocation",
                "athena:GetDataCatalog",
                "s3:AbortMultipartUpload",
                "s3:GetObject",
                "s3:PutObject",
                "athena:GetWorkGroup"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/*",
                "arn:aws:athena:{{us-east-2}}:{{111122223333}}:workgroup/{{workgroup-name}}"
            ]
        },
        {
            "Sid": "GetGlueConnections",
            "Effect": "Allow",
            "Action": [
                "glue:GetConnections",
                "glue:GetConnection"
            ],
            "Resource": [
                "arn:aws:glue:{{us-east-2}}:{{111122223333}}:catalog",
                "arn:aws:glue:{{us-east-2}}:{{111122223333}}:connection/*"
            ]
        },
        {
            "Sid": "GetSecrets",
            "Effect": "Allow",
            "Action": [                
                "secretsmanager:GetSecretValue"
            ],
            "Resource": [
                "arn:aws:secretsmanager:{{us-east-2}}:{{111122223333}}:secret:{{secret-name}}"       
            ]
        }
    ]
}
```

------

### Amazon Redshift と Amazon Redshift Serverless (ユーザー名とパスワード認証) / Snowflake
<a name="datasources-connection-permissions-snowflake-redshift-user-password"></a>

**注記**  
このポリシーは、必要なリソースのみとするようにスコープダウンすることを強くお勧めします。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "GetS3Metadata",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetObject",
                "s3:GetBucketLocation"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/*"
            ]
        },
        {
            "Sid": "GetGlueConnections",
            "Effect": "Allow",
            "Action": [
                "glue:GetConnections",
                "glue:GetConnection"
            ],
            "Resource": [
                "arn:aws:glue:{{us-east-2}}:{{111122223333}}:catalog",
                "arn:aws:glue:{{us-east-2}}:{{111122223333}}:connection/*"
            ]
        },
        {
            "Sid": "GetSecrets",
            "Effect": "Allow",
            "Action": [                
                "secretsmanager:GetSecretValue"
            ],
            "Resource": [
                "arn:aws:secretsmanager:{{us-east-2}}:{{111122223333}}:secret:{{secret-name}}"            
            ]
        }
    ]
}
```

------

### Amazon Redshift (IAM 認証)
<a name="datasources-connection-permissions-redshift-iam"></a>

**注記**  
このポリシーは、必要なリソースのみとするようにスコープダウンすることを強くお勧めします。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "GetS3Metadata",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetObject",
                "s3:GetBucketLocation"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/*",
                "arn:aws:s3:::{{amzn-s3-demo-bucket}}/*"
            ]
        },
        {
            "Sid": "GetGlueConnections",
            "Effect": "Allow",
            "Action": [
                "glue:GetConnections",
                "glue:GetConnection"
            ],
            "Resource": [
                "arn:aws:glue:{{us-east-1}}:{{111122223333}}:catalog",
                "arn:aws:glue:{{us-east-1}}:{{111122223333}}:connection/*",
                "arn:aws:glue:{{us-east-1}}:{{111122223333}}:connection/{{connection-name}}"
            ]
        },
        {
            "Sid": "GetSecrets",
            "Effect": "Allow",
            "Action": [
                "secretsmanager:GetSecretValue"
            ],
            "Resource": [
                "arn:aws:secretsmanager:{{us-east-1}}:{{111122223333}}:secret:{{secret-name}}",
                "arn:aws:secretsmanager:{{us-east-1}}:{{111122223333}}:secret:{{secret-name-with-suffix}}"
            ]
        },
        {
            "Sid": "GetClusterCredentials",
            "Effect": "Allow",
            "Action": [
                "redshift:GetClusterCredentials"
            ],
            "Resource": [
                "arn:aws:redshift:{{us-east-1}}:{{111122223333}}:cluster:{{cluster-name}}",
                "arn:aws:redshift:{{us-east-1}}:{{111122223333}}:dbuser:{{cluster-name}}/{{db-user-name}}"
            ]
        }
    ]
}
```

------

### Amazon Redshift Serverless (IAM 認証)
<a name="datasources-connection-permissions-redshift-serverless-iam"></a>

**注記**  
このポリシーは、必要なリソースのみとするようにスコープダウンすることを強くお勧めします。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "GetS3Metadata",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetObject",
                "s3:GetBucketLocation"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/*"
            ]
        },
        {
            "Sid": "GetGlueConnections",
            "Effect": "Allow",
            "Action": [
                "glue:GetConnections",
                "glue:GetConnection"
            ],
            "Resource": [
                "arn:aws:glue:{{us-east-2}}:{{111122223333}}:catalog",
                "arn:aws:glue:{{us-east-2}}:{{111122223333}}:connection/*"
            ]
        },
        {
            "Sid": "GetSecrets",
            "Effect": "Allow",
            "Action": [                
                "secretsmanager:GetSecretValue"
            ],
            "Resource": [
                "arn:aws:secretsmanager:{{us-east-2}}:{{111122223333}}:secret:{{secret-name}}"         
            ]
        },
        {
            "Sid": "GetRedshiftServerlessCredentials",
            "Effect": "Allow",
            "Action": [
                "redshift-serverless:GetCredentials"
            ],
            "Resource": [
                "arn:aws:redshift-serverless:{{us-east-2}}:{{111122223333}}:namespace/{{namespace-id}}"           
            ]
        }
    ]
}
```

------

## ユーザー定義の接続にに必要な IAM アクセス許可
<a name="user-defined-connections-permissions"></a>

ユーザーの IAM ポリシーのアクセス許可は、 AWS Glue 接続リソースに `UserProfile` タグが存在することを考慮できます。
+ ** AWS Glue 接続を表示するには**:
  + ユーザーは、(管理者が作成した) `UserProfile` タグが付けられていないすべての接続を表示できます。
  + ユーザーは、ユーザープロファイル名と同じ値を持つ `UserProfile` タグが付けられた接続を表示できます。
  + ユーザーは、自分自身のユーザープロファイル名とは異なる値の `UserProfile` タグが付けられた接続を表示できません。
+ ** AWS Glue 接続を更新または削除するには**:
  + ユーザーは、自分自身のユーザープロファイル名と同じ値の `UserProfile` タグが付けられた接続を更新または削除できます。
  + ユーザーは、自分自身のユーザープロファイル名とは異なる値の `UserProfile` タグが付けられた接続を更新または削除することはできません。
  + ユーザーは `UserProfile` タグが付けられていない接続を更新または削除することはできません。

これを実現するには、管理者はユーザープロファイルの JupyterLab アプリケーションで使用される実行ロールに、既存の[管理者定義の接続許可を超える追加の許可](#admin-defined-connections-permissions)を付与する必要があります。具体的には、管理者定義 AWS Glue の接続にアクセスするために必要なアクセス許可に加えて、次の 2 つの追加の IAM アクセス許可をユーザーの実行ロールに付与する必要があります。
+  AWS Glue 接続を作成し、`UserProfile`タグをユーザーのプロファイル名の値に関連付けるアクセス許可。
+ ユーザーのプロファイル名と一致する`UserProfile`タグを持つ AWS Glue 接続を表示、更新、削除するアクセス許可。

このアクセス許可は、特定のユーザープロファイルタグ値に基づいて AWS Glue 接続へのアクセスを制限します。ターゲットにするユーザーのプロファイル名で `UserProfile` タグ値を更新します。

```
"Action": [
    "glue:GetConnection",
    "glue:GetConnections"    
],
"Resource": [
    "arn:aws:glue:{{region}}:{{account_id}}:connection/*"
],
"Condition": {
    "StringEqualsIfExists": {
        "aws:ResourceTag/UserProfile": "{{user_profile_name}}"
    }
}
```

このアクセス許可は、ユーザーが作成した接続を作成、更新、削除する機能を、指定された `UserProfile` タグ値を持つユーザープロファイルが作成した接続のみに制限します。

```
"Action": [
    "glue:DeleteConnection",
    "glue:UpdateConnection",
    "glue:CreateConnection",
    "glue:TagResource"
],
"Resource": [
    "arn:aws:glue:{{region}}:{{account_id}}:connection/*"
],
"Condition": {
    "StringEquals": {
        "aws:ResourceTag/UserProfile": "{{user_profile}}"
    }
}
```

## きめ細かな ARN アクセス許可で AWS リソースアクセスを微調整する
<a name="resource-access-control"></a>

 AWS リソースへのアクセスをよりきめ細かく制御するには、ポリシー`"Resource": ["*"]`内のワイルドカードリソースを、アクセスを必要とするリソースのみの特定の Amazon リソースネーム (ARNsに置き換えます。ワイルドカードではなく正確な ARN を使用すると、意図するリソースへのアクセスを制限できます。
+ **特定の Amazon S3 バケットの ARN を使用する**

  例えば、バケットレベルまたはオブジェクトレベルのオペレーションの場合、`"arn:aws:s3:::bucket-name"` または ` "arn:aws:s3:::bucket-name/*"` を使用します。

  Amazon S3 のすべてのリソースタイプの詳細については、「[Amazon S3 で定義されるリソースタイプ](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html#amazons3-resources-for-iam-policies)」を参照してください。
+ **特定の AWS Glue データベース ARNs**

  例えば、` "arn:aws:glue:region:account-id:catalog"`、` "arn:aws:glue:region:account-id:database/db-name"` などです。のすべてのリソースタイプの詳細については AWS Glue、「 [で定義されるリソースタイプ AWS Glue](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsglue.html#awsglue-resources-for-iam-policies)」を参照してください。
+ **特定の Athena ワークグループの ARN を使用する**

  例: `"arn:aws:athena:region:account-id:workgroup/workgroup-name"`。Athena のすべてのリソースタイプの詳細については、「[Resource types defined by Athena](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonathena.html#amazonathena-resources-for-iam-policies)」を参照してください。
+ **特定の AWS Secrets Manager シークレット ARNs**

  例: `"arn:aws:secretsmanager:region:account-id:secret:secret-name"`。 AWS Secrets Manager のすべてのリソースタイプの詳細については、[AWS 「Secrets Manager で定義されるリソースタイプ](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssecretsmanager.html#awssecretsmanager-resources-for-iam-policies)」を参照してください。
+ **特定の Amazon Redshift クラスターの ARN を使用する**

  例: `"arn:aws:redshift:region:account-id:cluster:cluster-name"`。Amazon Redshift のリソースタイプの詳細については、「[Resource types defined by Amazon Redshift](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonredshift.html#amazonredshift-resources-for-iam-policies)」を参照してください。Redshift Serverless のすべてのリソースタイプの詳細については、「[Resource types defined by Redshift Serverless](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonredshiftserverless.html#amazonredshiftserverless-resources-for-iam-policies)」を参照してください。