

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

# 在 CloudTrail 日誌中包含 IAM Identity Center 使用者內容
<a name="identity-center-ct-logs"></a>

Lake Formation 使用[憑證販賣](using-cred-vending.md)功能來暫時存取 Amazon S3 資料。根據預設，當 IAM Identity Center 使用者向整合的分析服務提交查詢時，CloudTrail 日誌只會包含服務擔任的 IAM 角色，以提供短期存取。如果您使用使用者定義的角色向 Lake Formation 註冊 Amazon S3 資料位置，您可以選擇在 CloudTrail 事件中包含 IAM Identity Center 使用者的內容，然後追蹤存取 資源的使用者。

**重要**  
若要在 CloudTrail 中包含物件層級的 Amazon S3 API 請求，您需要為 Amazon S3 儲存貯體和物件啟用 CloudTrail 事件記錄。如需更多內建，請參閱《[Amazon S3 使用者指南》中的啟用 Amazon S3 儲存貯體和物件的 CloudTrail 事件記錄](https://docs.aws.amazon.com/AmazonS3/latest/userguide/enable-cloudtrail-logging-for-s3.html)。 Amazon S3 

**在向使用者定義角色註冊的資料湖位置上啟用憑證販賣稽核**

1. 登入 Lake Formation 主控台，網址為 https：//[https://console.aws.amazon.com/lakeformation/](https://console.aws.amazon.com/lakeformation/)。

1. 在左側導覽中，展開**管理**，然後選擇 **Data Catalog 設定**。

1. 在**增強型稽核**下，選擇**傳播提供的內容。**

1. 選擇**儲存**。

 您也可以在 [PutDataLakeSettings](https://docs.aws.amazon.com/lake-formation/latest/APIReference/API_PutDataLakeSettings.html) 操作中設定 `Parameters` 屬性，以啟用增強型稽核選項。根據預設， `SET_CONTEXT"` 參數值設定為「true」。

```
{
    "DataLakeSettings": {
        "Parameters": {"SET_CONTEXT": "true"},
    }
}
```

以下是 CloudTrail 事件的摘錄，其中包含增強型稽核選項。此日誌包含 IAM Identity Center 使用者的工作階段內容，以及 Lake Formation 擔任以存取 Amazon S3 資料位置的使用者定義 IAM 角色。請參閱下列摘錄中的 `onBehalfOf` 參數。

```
{
         "eventVersion":"1.09",
         "userIdentity":{
            "type":"AssumedRole",
            "principalId":"AROAW7F7MOX4OYE6FLIFN:access-grants-e653760c-4e8b-44fd-94d9-309e035b75ab",
            "arn":"arn:aws:sts::123456789012:assumed-role/accessGrantsTestRole/access-grants-e653760c-4e8b-44fd-94d9-309e035b75ab",           
            "accountId":"123456789012",
            "accessKeyId":"ASIAW7F7MOX4CQLD4JIZN",
            "sessionContext":{
               "sessionIssuer":{
                  "type":"Role",
                  "principalId":"AROAW7F7MOX4OYE6FLIFN",
                  "arn":"arn:aws:iam::123456789012:role/accessGrantsTestRole",
                  "accountId":"123456789012",
                  "userName":"accessGrantsTestRole"
               },
               "attributes":{
                  "creationDate":"2023-08-09T17:24:02Z",
                  "mfaAuthenticated":"false"
               }
            },
            "onBehalfOf":{
                "userId": "<identityStoreUserId>",
                "identityStoreArn": "arn:aws:identitystore::<restOfIdentityStoreArn>"
            }
         },
         "eventTime":"2023-08-09T17:25:43Z",
         "eventSource":"s3.amazonaws.com",
         "eventName":"GetObject",
    ....
```