本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
設定 IAM 許可以存取資料來源 (適用於管理員)
管理員應確保 JupyterLab 應用程式使用的執行角色具有必要的 AWSIAM 許可,以透過設定的AWS Glue連線存取資料。
-
管理員使用 建立的連線AWS CLI:若要檢視管理員建立的AWS Glue連線並存取其資料,使用者需要讓管理員將特定許可連接到 Studio 中 JupyterLab 應用程式所使用的 SageMaker AI 執行角色。這包括對 AWS Glue的存取、Secrets Manager 和資料庫特定的許可。共用執行角色的所有應用程式都可以看到管理員建立的連線,因為此執行角色獲授予檢視特定 AWS Glue 目錄或資料庫的許可。若要了解每種資料來源類型的必要許可清單,請參閱管理員定義的連線需要 IAM 許可中管理員定義的連線許可。
-
使用者在 JupyterLab 中使用 SQL 延伸模組 UI 建立的連線:除非連線的可見性範圍縮小至使用者建立的連線,否則也會列出共用相同執行角色的使用者設定檔建立的連線。使用者建立的連線會透過建立它們的使用者設定檔加以標記。若要限制僅建立連線的使用者才能檢視、更新或刪除這些使用者建立的連線,管理員可以將其他標籤型存取控制限制新增至執行角色 IAM 許可。若要了解所需的其他標籤型存取控制,請參閱使用者定義的連線需要 IAM 許可。
管理員定義的連線需要 IAM 許可
若要授予 Studio 中 JupyterLab 應用程式使用的 SageMaker AI 執行角色透過 AWS Glue連線存取資料來源,請將下列內嵌政策連接至角色。
若要檢視每個資料來源或驗證方法的特定許可和政策詳細資訊,請選擇下面的相關連線類型。
建議您將政策的許可限制為僅必要的資源和動作。
若要縮小政策範圍並授予最低權限存取,請將政策中的 "Resource": ["*"] 萬用字元取代為需要存取的確切資源的特定 ARN。如需如何控制資源存取的詳細資訊,請參閱使用精細 ARN 許可微調AWS資源存取。
我們強烈建議將此政策範圍縮小到僅限必要的動作和資源。
- 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 文件中的範例 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"
]
}
]
}
- 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"
]
}
]
}
- 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"
]
}
]
}
- 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 許可
使用者的 IAM 政策許可可以考慮AWS Glue連線資源上是否存在UserProfile標籤。
-
若要檢視AWS Glue連線:
-
使用者可以檢視沒有 UserProfile 標籤的所有連線 (由管理員建立)。
-
使用者可以檢視其具有的 UserProfile 標籤含有與其使用者設定檔相同值的連線。
-
使用者無法檢視其具有的 UserProfile 標籤含有與其使用者設定檔不同值的連線。
-
若要更新或刪除AWS Glue連線:
-
使用者可以更新或刪除其具有的 UserProfile 標籤含有與其使用者設定檔相同值的連線。
-
使用者無法更新或刪除其具有的 UserProfile 標籤含有與其使用者設定檔不同值的連線。
-
使用者無法更新或刪除沒有 UserProfile 標籤的連線。
若要達成此目的,管理員必須授予使用者設定檔的 JupyterLab 應用程式所使用的執行角色,超出其現有管理員定義連線許可的額外許可。具體而言,除了存取管理員定義AWS Glue連線所需的許可之外,還必須授予以下兩個額外的 IAM 許可給使用者的執行角色:
此許可會根據特定使用者設定檔標籤值,限制對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資源存取
若要更精細地控制對AWS資源的存取,請將政策"Resource": ["*"]中的萬用字元資源取代為僅需要存取之資源的特定 Amazon Resource Name (ARNs)。使用確切 ARN 而非萬用字元可限制對預期資源的存取。
-
使用特定的 Amazon S3 儲存貯體 ARN
例如,儲存貯體層級或物件層級操作的
"arn:aws:s3:::bucket-name/*" 或 "arn:aws:s3:::bucket-name"。
如需 Amazon S3 中所有資源類型的相關資訊,請參閱 Amazon S3 定義的資源類型。
-
使用特定AWS Glue資料庫 ARNs
例如 "arn:aws:glue:region:account-id:catalog" 或
"arn:aws:glue:region:account-id:database/db-name"。如需 中所有資源類型的資訊AWS Glue,請參閱 定義的資源類型AWS Glue。
-
使用特定的 Athena 工作群組 ARN
例如 "arn:aws:athena:region:account-id:workgroup/workgroup-name"。如需 Athena 中所有資源類型的相關資訊,請參閱 Athena 定義的資源類型。
-
使用特定的 AWSSecrets Manager 秘密 ARNs
例如 "arn:aws:secretsmanager:region:account-id:secret:secret-name"。如需 AWSSecrets Manager 中所有資源類型的資訊,請參閱 AWSSecrets Manager 定義的資源類型
-
使用特定的 Amazon Redshift 叢集 ARN
例如 "arn:aws:redshift:region:account-id:cluster:cluster-name"。如需 Amazon Redshift 中所有資源類型的相關資訊,請參閱 Amazon Redshift 定義的資源類型。如需 Redshift Serverless 中所有資源類型的相關資訊,請參閱 Redshift Serverless 定義的資源類型。