

**支援終止通知：**2026 年 10 月 30 日， AWS 將結束對 Amazon Pinpoint 的支援。2026 年 10 月 30 日之後，您將無法再存取 Amazon Pinpoint 主控台或 Amazon Pinpoint 資源 (端點、區段、行銷活動、旅程和分析)。如需詳細資訊，請參閱 [Amazon Pinpoint 終止支援](https://docs.aws.amazon.com/console/pinpoint/migration-guide)。**注意：**與 SMS、語音、行動推播、OTP 和電話號碼驗證相關的 APIs 不受此變更影響，並受 AWS 最終使用者傳訊支援。

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

# 將事件串流到 Kinesis 的 IAM 角色
<a name="permissions-streams"></a>

Amazon Pinpoint 可以自動將應用程式用量資料或*事件資料*從您的應用程式傳送至 AWS 帳戶中的 Amazon Kinesis 資料串流或 Amazon Data Firehose 交付串流。您必須先將所需許可委派給 Amazon Pinpoint，Amazon Pinpoint 才能開始串流事件資料。

如果您使用主控台設定事件串流，Amazon Pinpoint 會自動建立具有必要許可的 AWS Identity and Access Management (IAM) 角色。如需詳細資訊，請參閱《[Amazon Pinpoint 使用者指南》中的將 Amazon Pinpoint 事件串流至 Kinesis](https://docs.aws.amazon.com/pinpoint/latest/userguide/analytics-streaming.html#analytics-streaming-kinesis)。 *Amazon Pinpoint *

如果您要手動建立角色，請將以下政策連接到角色：
+ 允許 Amazon Pinpoint 將事件資料傳送到您串流的許可政策。
+ 允許 Amazon Pinpoint 擔任角色的信任政策。

建立角色後，可以設定 Amazon Pinpoint 自動將事件傳送到您的串流。如需詳細資訊，請參閱本指南中的 [使用 Amazon Pinpoint 透過 Kinesis 和 Firehose 串流應用程式事件資料](event-streams.md)。

## 建立 IAM 角色 (AWS CLI)
<a name="permissions-streams-create"></a>

完成以下步驟來使用 AWS Command Line Interface (AWS CLI) 手動建立 IAM 角色。若要了解如何使用 Amazon Pinpoint 主控台建立角色，請參閱 *Amazon Pinpoint 使用者指南*中的[將 Amazon Pinpoint 事件串流到 Amazon Kinesis](https://docs.aws.amazon.com/pinpoint/latest/userguide/analytics-streaming.html#analytics-streaming-kinesis)。

如果您尚未安裝 AWS CLI，請參閱*AWS Command Line Interface 《 使用者指南*》中的[安裝 AWS CLI](https://docs.aws.amazon.com//cli/latest/userguide/getting-started-install.html) 。您也需要建立 Kinesis 串流或 Firehose 串流。如需有關建立這些資源的資訊，請參閱《*Amazon Kinesis Data* [Streams 開發人員指南》中的建立和管理](https://docs.aws.amazon.com/streams/latest/dev/working-with-streams.html)串流，或《[Amazon Data Firehose 開發人員指南》中的建立 Amazon Data Firehose 交付串流](https://docs.aws.amazon.com/firehose/latest/dev/basic-create.html)。 **

**使用 建立 IAM 角色 AWS CLI**

1. 建立新檔案。將下列政策貼到文件中，並進行下列變更：
   + 將*區域*取代為您使用 Amazon Pinpoint AWS 的區域。
   + 將 *accountId* 取代為您 AWS 帳戶的唯一 ID。
   + 以專案的唯一 ID 取代 *applicationId*。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Effect": "Allow",
               "Principal": {
                   "Service": "pinpoint.amazonaws.com"
               },
               "Action": "sts:AssumeRole",
               "Condition": {
                   "StringEquals": {
                       "aws:SourceAccount": "111122223333"
                   },
                   "ArnLike": {
                   "aws:SourceArn": "arn:aws:mobiletargeting:us-east-1:111122223333:apps/applicationId"
                   }
               }
           }
       ]
   }
   ```

------

   完成後，請將檔案儲存為 `PinpointEventStreamTrustPolicy.json`。

1. 使用 [https://docs.aws.amazon.com/cli/latest/reference/iam/create-role.html](https://docs.aws.amazon.com/cli/latest/reference/iam/create-role.html) 命令來建立角色，並連接信任政策：

   ```
   aws iam create-role --role-name PinpointEventStreamRole --assume-role-policy-document file://PinpointEventStreamTrustPolicy.json
   ```

1. 建立一個新檔案，內含您角色的許可政策。

   如果您要設定 Amazon Pinpoint 將資料傳送至 Kinesis 串流，請將下列政策貼入 檔案，並取代下列項目：
   + 將*區域*取代為您使用 Amazon Pinpoint AWS 的區域。
   + 將 *accountId* 取代為您 AWS 帳戶的唯一 ID。
   + 以 Kinesis 串流的名稱取代 *streamName*。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": {
           "Action": [
               "kinesis:PutRecords",
               "kinesis:DescribeStream"
           ],
           "Effect": "Allow",
           "Resource": [
               "arn:aws:kinesis:us-east-1:111122223333:stream/streamName"
           ]
       }
   }
   ```

------

   或者，如果您設定 Amazon Pinpoint 將資料傳送至 Firehose 串流，請將下列政策貼入 檔案，並取代下列項目：
   + 將*區域*取代為您使用 Amazon Pinpoint AWS 的區域。
   + 將 *accountId* 取代為您 AWS 帳戶的唯一 ID。
   + 將 *delivery-stream-name* 取代為您 Firehose 串流的名稱。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": {
           "Effect": "Allow",
           "Action": [
               "firehose:PutRecordBatch",
               "firehose:DescribeDeliveryStream"
           ],
           "Resource": [
               "arn:aws:firehose:us-east-1:111122223333:deliverystream/delivery-stream-name"
           ]
       }
   }
   ```

------

   完成後，請將檔案儲存為 `PinpointEventStreamPermissionsPolicy.json`。

1. 使用 [https://docs.aws.amazon.com/cli/latest/reference/iam/put-role-policy.html](https://docs.aws.amazon.com/cli/latest/reference/iam/put-role-policy.html) 命令將許可政策連接到角色：

   ```
   aws iam put-role-policy --role-name PinpointEventStreamRole --policy-name PinpointEventStreamPermissionsPolicy --policy-document file://PinpointEventStreamPermissionsPolicy.json
   ```