

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

# 使用 記錄 AWS 付款密碼編譯 API 呼叫 AWS CloudTrail
<a name="monitoring-cloudtrail"></a>

AWS 付款密碼編譯已與 服務整合 AWS CloudTrail，此服務提供使用者、角色或 AWS 服務在 AWS 付款密碼編譯中採取之動作的記錄。CloudTrail 會將 AWS 付款密碼編譯的所有 API 呼叫擷取為事件。擷取的呼叫包括從 主控台進行的呼叫，以及針對 API 操作的程式碼呼叫。如果您建立線索，則可以將 CloudTrail 事件持續交付至 Amazon S3 儲存貯體，包括 AWS 付款密碼編譯的事件。如果您未設定線索，仍然可以在 CloudTrail 主控台的事件**歷史記錄中檢視最新的管理 （控制平面） 事件**。您可以使用 CloudTrail 所收集的資訊，判斷對 AWS 付款密碼編譯提出的請求、提出請求的 IP 地址、提出請求的人員、提出請求的時間，以及其他詳細資訊。

若要進一步了解 CloudTrail，請參閱[「AWS CloudTrail 使用者指南」](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/)。

**Topics**
+ [AWS CloudTrail 中的付款密碼編譯資訊](#service-name-info-in-cloudtrail)
+ [CloudTrail 中的控制平面事件](#management-events-in-cloud-trail)
+ [CloudTrail 中的資料事件](#data-events-in-cloud-trail)
+ [了解 AWS 付款密碼編譯控制平面日誌檔案項目](#understanding-controlplane-entries)
+ [了解 AWS 付款密碼編譯資料平面日誌檔案項目](#understanding-dataplane-entries)

## AWS CloudTrail 中的付款密碼編譯資訊
<a name="service-name-info-in-cloudtrail"></a>

當您建立 AWS 帳戶時，會在您的帳戶上啟用 CloudTrail。當活動在 AWS 付款密碼編譯中發生時，該活動會與**事件歷史記錄**中的其他服務 AWS 事件一起記錄在 CloudTrail 事件中。您可以檢視、搜尋和下載 AWS 帳戶的最新事件。如需詳細資訊，請參閱[使用 CloudTrail 事件歷史記錄檢視事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)。

若要持續記錄您 AWS 帳戶中的事件，包括 AWS 付款密碼編譯的事件，請建立追蹤。*線索*能讓 CloudTrail 將日誌檔案交付至 Amazon S3 儲存貯體。根據預設，當您在主控台建立線索時，線索會套用到所有 AWS 區域。線索會記錄 AWS 分割區中所有區域的事件，並將日誌檔案傳送到您指定的 Amazon S3 儲存貯體。此外，您可以設定其他 AWS 服務，以進一步分析和處理 CloudTrail 日誌中所收集的事件資料。如需詳細資訊，請參閱下列內容：
+ [建立追蹤的概觀](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)
+ [CloudTrail 支援的服務和整合](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-aws-service-specific-topics.html#cloudtrail-aws-service-specific-topics-integrations)
+ [設定 CloudTrail 的 Amazon SNS 通知](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/getting_notifications_top_level.html)
+ [從多個區域接收 CloudTrail 日誌檔案](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html)
+ [從多個帳戶接收 CloudTrail 日誌檔案](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-receive-logs-from-multiple-accounts.html)

每一筆事件或日誌項目都會包含產生請求者的資訊。身分資訊可協助您判斷下列事項：
+ 是否使用根或 AWS Identity and Access Management (IAM) 使用者登入資料提出請求。
+ 提出該請求時，是否使用了特定角色或聯合身分使用者的暫時安全憑證。
+ 請求是否由其他 AWS 服務提出。

如需詳細資訊，請參閱 [CloudTrail userIdentity 元素](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-user-identity.html)。

## CloudTrail 中的控制平面事件
<a name="management-events-in-cloud-trail"></a>

CloudTrail 會記錄 AWS 付款密碼編譯操作，例如 [CreateKey](https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_CreateKey.html)、[ImportKey](https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_ImportKey.html)、[DeleteKey](https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_DeleteKey.html)、[ListKeys](https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_ListKeys.html)、[TagResource](https://docs.aws.amazon.com/payment-cryptography/latest/APIReference/API_TagResource.html) 和所有其他控制平面操作。

## CloudTrail 中的資料事件
<a name="data-events-in-cloud-trail"></a>

 [ 資料事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html#logging-data-events.html)提供有關在資源上執行或在資源中執行的資源操作的資訊，例如加密承載或翻譯接腳。資料事件是 CloudTrail 預設不會記錄的大量活動。您可以使用 CloudTrail API 或主控台，為 AWS 付款密碼編譯資料平面事件啟用資料事件 APIs 動作記錄。如需詳細資訊，請參閱《AWS CloudTrail 使用者指南》**中的[記錄資料事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-data-events-with-cloudtrail.html)。

 使用 CloudTrail，您必須使用進階事件選取器來決定記錄和記錄哪些 AWS 付款密碼編譯 API 活動。若要記錄 AWS 付款密碼編譯資料平面事件，您必須包含 資源類型 `AWS Payment Cryptography key`和 `AWS Payment Cryptography alias`。設定此選項後，您可以藉由選取要記錄的特定資料事件 (例如使用 `eventName` 篩選條件追蹤 `EncryptData` 事件)，進一步調整記錄偏好設定。如需詳細資訊，請參閱 *AWS CloudTrail API 參考*中的 [https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_AdvancedEventSelector.html](https://docs.aws.amazon.com/awscloudtrail/latest/APIReference/API_AdvancedEventSelector.html)。

**注意**  
若要訂閱 AWS 付款密碼編譯資料事件，您必須使用進階事件選取器。我們建議您訂閱金鑰和別名事件，以確保您收到所有事件。

**AWS 付款密碼編譯資料事件：**
+ `[DecryptData](https://docs.aws.amazon.com/payment-cryptography/latest/DataAPIReference/API_DecryptData.html)`
+ `[EncryptData](https://docs.aws.amazon.com/payment-cryptography/latest/DataAPIReference/API_EncryptData.html)`
+ `[GenerateCardValidationData](https://docs.aws.amazon.com/payment-cryptography/latest/DataAPIReference/API_GenerateCardValidationData.html)`
+ `[GenerateMac](https://docs.aws.amazon.com/payment-cryptography/latest/DataAPIReference/API_GenerateMac.html)`
+ `[GeneratePinData](https://docs.aws.amazon.com/payment-cryptography/latest/DataAPIReference/API_GeneratePinData.html)`
+ `[ReEncryptData](https://docs.aws.amazon.com/payment-cryptography/latest/DataAPIReference/API_ReEncryptData.html)`
+ `[TranslatePinData](https://docs.aws.amazon.com/payment-cryptography/latest/DataAPIReference/API_TranslatePinData.html)`
+ `[VerifyAuthRequestCryptogram](https://docs.aws.amazon.com/payment-cryptography/latest/DataAPIReference/API_VerifyAuthRequestCryptogram.html)`
+ `[VerifyCardValidationData](https://docs.aws.amazon.com/payment-cryptography/latest/DataAPIReference/API_VerifyCardValidationData.html)`
+ `[VerifyMac](https://docs.aws.amazon.com/payment-cryptography/latest/DataAPIReference/API_VerifyMac.html)`
+ `[VerifyPinData](https://docs.aws.amazon.com/payment-cryptography/latest/DataAPIReference/API_VerifyPinData.html)`

 資料事件需支付額外的費用。如需詳細資訊，請參閱 [AWS CloudTrail 定價](https://aws.amazon.com/cloudtrail/pricing/)。

## 了解 AWS 付款密碼編譯控制平面日誌檔案項目
<a name="understanding-controlplane-entries"></a>

追蹤是一種組態，能讓事件以日誌檔案的形式交付到您指定的 Amazon S3 儲存貯體。CloudTrail 日誌檔案包含一或多個日誌專案。一個事件為任何來源提出的單一請求，並包含請求動作、請求的日期和時間、請求參數等資訊。CloudTrail 日誌檔並非依公有 API 呼叫的堆疊追蹤排序，因此不會以任何特定順序出現。

下列範例顯示示範 AWS 付款密碼編譯`CreateKey`動作的 CloudTrail 日誌項目。

```
      {
    CloudTrailEvent: {
      tlsDetails= {
        TlsDetails: {
          cipherSuite=TLS_AES_128_GCM_SHA256, 
          tlsVersion=TLSv1.3, 
          clientProvidedHostHeader=controlplane.paymentcryptography.us-west-2.amazonaws.com
        }
      }, 
    requestParameters=CreateKeyInput (
      keyAttributes=KeyAttributes(
        KeyUsage=TR31_B0_BASE_DERIVATION_KEY, 
        keyClass=SYMMETRIC_KEY, 
        keyAlgorithm=AES_128, 
        keyModesOfUse=KeyModesOfUse(
          encrypt=false,
          decrypt=false,
          wrap=false
          unwrap=false,
          generate=false,
          sign=false, 
          verify=false,
          deriveKey=true,
          noRestrictions=false)
        ), 
      keyCheckValueAlgorithm=null, 
      exportable=true, 
      enabled=true, 
      tags=null), 
    eventName=CreateKey, 
    userAgent=Coral/Apache-HttpClient5, 
    responseElements=CreateKeyOutput(
      key=Key(
        keyArn=arn:aws:payment-cryptography:us-east-2:111122223333:key/5rplquuwozodpwsp, 
          keyAttributes=KeyAttributes(
            KeyUsage=TR31_B0_BASE_DERIVATION_KEY, 
            keyClass=SYMMETRIC_KEY, 
            keyAlgorithm=AES_128, 
            keyModesOfUse=KeyModesOfUse(
              encrypt=false, 
              decrypt=false, 
              wrap=false, 
              unwrap=false, 
              generate=false,
              sign=false,
              verify=false,
              deriveKey=true,
              noRestrictions=false)
            ), 
          keyCheckValue=FE23D3, 
          keyCheckValueAlgorithm=ANSI_X9_24, 
          enabled=true, 
          exportable=true, 
          keyState=CREATE_COMPLETE, 
          keyOrigin=AWS_PAYMENT_CRYPTOGRAPHY, 
          createTimestamp=Sun May 21 18:58:32 UTC 2023, 
          usageStartTimestamp=Sun May 21 18:58:32 UTC 2023, 
          usageStopTimestamp=null, 
          deletePendingTimestamp=null, 
          deleteTimestamp=null)
        ), 
      sourceIPAddress=192.158.1.38, 
        userIdentity={
          UserIdentity: {
            arn=arn:aws:sts::111122223333:assumed-role/TestAssumeRole-us-west-2/ControlPlane-IntegTest-68211a2a-3e9d-42b7-86ac-c682520e0410, 
            invokedBy=null, 
            accessKeyId=TESTXECZ5U2ZULLHHMJG, 
            type=AssumedRole, 
            sessionContext={
              SessionContext: {
                sessionIssuer={
                  SessionIssuer: {arn=arn:aws:iam::111122223333:role/TestAssumeRole-us-west-2, 
                  type=Role, 
                  accountId=111122223333, 
                  userName=TestAssumeRole-us-west-2, 
                  principalId=TESTXECZ5U9M4LGF2N6Y5}
                }, 
                attributes={
                  SessionContextAttributes: {
                    creationDate=Sun May 21 18:58:31 UTC 2023,
                    mfaAuthenticated=false
                  }
                },
                webIdFederationData=null
              }
            },
          username=null, 
          principalId=TESTXECZ5U9M4LGF2N6Y5:ControlPlane-User, 
          accountId=111122223333,
          identityProvider=null
        }
      }, 
      eventTime=Sun May 21 18:58:32 UTC 2023, 
      managementEvent=true, 
      recipientAccountId=111122223333, 
      awsRegion=us-west-2, 
      requestID=151cdd67-4321-1234-9999-dce10d45c92e, 
      eventVersion=1.08, eventType=AwsApiCall, 
      readOnly=false, 
      eventID=c69e3101-eac2-1b4d-b942-019919ad2faf, 
      eventSource=payment-cryptography.amazonaws.com, 
      eventCategory=Management, 
      additionalEventData={
    }
  }
}
```

下列範例顯示 CloudTrail 日誌項目，示範啟用多區域金鑰複寫的 AWS 付款密碼編譯。

```
{
    "eventVersion": "1.11",
    "userIdentity": {
        "accountId": "111122223333",
        "invokedBy": "payment-cryptography.amazonaws.com"
    },
    "eventTime": "2025-08-15T17:50:41Z",
    "eventSource": "payment-cryptography.amazonaws.com",
    "eventName": "SynchronizeMultiRegionKey",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "payment-cryptography.amazonaws.com",
    "userAgent": "payment-cryptography.amazonaws.com",
    "requestParameters": null,
    "responseElements": null,
    "eventID": "55c0fcbc-5b2e-4bd2-a976-99305be6e6fc",
    "readOnly": false,
    "eventType": "AwsServiceEvent",
    "managementEvent": true,
    "recipientAccountId": "111122223333",
    "serviceEventDetails": {
        "keyArn": "arn:aws:payment-cryptography:us-east-1:111122223333:key/key-id",
        "replicationRegion": "us-east-2"
    },
    "eventCategory": "Management"
}
```

## 了解 AWS 付款密碼編譯資料平面日誌檔案項目
<a name="understanding-dataplane-entries"></a>

資料平面事件可以選擇性地設定和運作，類似於控制平面日誌，但通常磁碟區較高。由於某些輸入和輸出對 AWS 付款密碼編譯資料平面操作的敏感性質，您可能會找到具有「\$1\$1\$1 敏感資料修訂 \$1\$1\$1」訊息的特定欄位。這無法設定，旨在防止敏感資料出現在日誌或追蹤中。

下列範例顯示示範 AWS 付款密碼編譯`EncryptData`動作的 CloudTrail 日誌項目。

```
      {
        "Records": [
            {
                "eventVersion": "1.09",
                "userIdentity": {
                    "type": "AssumedRole",
                    "principalId": "TESTXECZ5U2ZULLHHMJG:DataPlane-User",
                    "arn": "arn:aws:sts::111122223333:assumed-role/Admin/DataPlane-User",
                    "accountId": "111122223333",
                    "accessKeyId": "TESTXECZ5U2ZULLHHMJG",
                    "userName": "",
                    "sessionContext": {
                        "sessionIssuer": {
                            "type": "Role",
                            "principalId": "TESTXECZ5U9M4LGF2N6Y5",
                            "arn": "arn:aws:iam::111122223333:role/Admin",
                            "accountId": "111122223333",
                            "userName": "Admin"
                        },
                        "attributes": {
                            "creationDate": "2024-07-09T14:23:05Z",
                            "mfaAuthenticated": "false"
                        }
                    }
                },
                "eventTime": "2024-07-09T14:24:02Z",
                "eventSource": "payment-cryptography.amazonaws.com",
                "eventName": "GenerateCardValidationData",
                "awsRegion": "us-east-2",
                "sourceIPAddress": "192.158.1.38",
                "userAgent": "aws-cli/2.17.6 md/awscrt#0.20.11 ua/2.0 os/macos#23.4.0 md/arch#x86_64 lang/python#3.11.8 md/pyimpl#CPython cfg/retry-mode#standard md/installer#exe md/prompt#off md/command#payment-cryptography-data.generate-card-validation-data",
                "requestParameters": {
                    "key_identifier": "arn:aws:payment-cryptography:us-east-2:111122223333:key/5rplquuwozodpwsp",
                    "primary_account_number": "*** Sensitive Data Redacted ***",
                    "generation_attributes": {
                        "CardVerificationValue2": {
                            "card_expiry_date": "*** Sensitive Data Redacted ***"
                        }
                    }
                },
                "responseElements": null,
                "requestID": "f2a99da8-91e2-47a9-b9d2-1706e733991e",
                "eventID": "e4eb3785-ac6a-4589-97a1-babdd3d4dd95",
                "readOnly": true,
                "resources": [
                    {
                        "accountId": "111122223333",
                        "type": "AWS::PaymentCryptography::Key",
                        "ARN": "arn:aws:payment-cryptography:us-east-2:111122223333:key/5rplquuwozodpwsp"
                    }
                ],
                "eventType": "AwsApiCall",
                "managementEvent": false,
                "recipientAccountId": "111122223333",
                "eventCategory": "Data",
                "tlsDetails": {
                    "tlsVersion": "TLSv1.3",
                    "cipherSuite": "TLS_AES_128_GCM_SHA256",
                    "clientProvidedHostHeader": "dataplane.payment-cryptography.us-east-2.amazonaws.com"
                }
            }
        ]
    }
```