將事件串流到 Kinesis 的 IAM 角色 - Amazon Pinpoint

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

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

將事件串流到 Kinesis 的 IAM 角色

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

如果您使用主控台設定事件串流,Amazon Pinpoint 會自動建立具有必要許可的 AWS Identity and Access Management (IAM) 角色。如需詳細資訊,請參閱《Amazon Pinpoint 使用者指南》中的將 Amazon Pinpoint 事件串流至 KinesisAmazon Pinpoint

如果您要手動建立角色,請將以下政策連接到角色:

  • 允許 Amazon Pinpoint 將事件資料傳送到您串流的許可政策。

  • 允許 Amazon Pinpoint 擔任角色的信任政策。

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

建立 IAM 角色 (AWS CLI)

完成以下步驟來使用 AWS Command Line Interface (AWS CLI) 手動建立 IAM 角色。若要了解如何使用 Amazon Pinpoint 主控台建立角色,請參閱 Amazon Pinpoint 使用者指南中的將 Amazon Pinpoint 事件串流到 Amazon Kinesis

如果您尚未安裝 AWS CLI,請參閱AWS Command Line Interface 《 使用者指南》中的安裝 AWS CLI 。您也需要建立 Kinesis 串流或 Firehose 串流。如需有關建立這些資源的資訊,請參閱《Amazon Kinesis Data Streams 開發人員指南》中的建立和管理串流,或《Amazon Data Firehose 開發人員指南》中的建立 Amazon Data Firehose 交付串流

使用 建立 IAM 角色 AWS CLI
  1. 建立新檔案。將下列政策貼到文件中,並進行下列變更:

    • 區域取代為您使用 Amazon Pinpoint AWS 的區域。

    • accountId 取代為您 AWS 帳戶的唯一 ID。

    • applicationId 取代為專案的唯一 ID。

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

    完成後,請將檔案儲存為 PinpointEventStreamTrustPolicy.json

  2. 使用 create-role 命令來建立角色,並連接信任政策:

    aws iam create-role --role-name PinpointEventStreamRole --assume-role-policy-document file://PinpointEventStreamTrustPolicy.json
  3. 建立一個新檔案,內含您角色的許可政策。

    如果您要設定 Amazon Pinpoint 將資料傳送至 Kinesis 串流,請將下列政策貼入 檔案,並取代下列項目:

    • 區域取代為您使用 Amazon Pinpoint AWS 的區域。

    • accountId 取代為您 AWS 帳戶的唯一 ID。

    • 以 Kinesis 串流的名稱取代 streamName

    { "Version": "2012-10-17", "Statement": { "Action": [ "kinesis:PutRecords", "kinesis:DescribeStream" ], "Effect": "Allow", "Resource": [ "arn:aws:kinesis:region:accountId:stream/streamName" ] } }

    或者,如果您設定 Amazon Pinpoint 將資料傳送至 Firehose 串流,請將下列政策貼入 檔案,並取代下列項目:

    • 區域取代為您使用 Amazon Pinpoint AWS 的區域。

    • accountId 取代為您 AWS 帳戶的唯一 ID。

    • delivery-stream-name 取代為您 Firehose 串流的名稱。

    { "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Action": [ "firehose:PutRecordBatch", "firehose:DescribeDeliveryStream" ], "Resource": [ "arn:aws:firehose:region:accountId:deliverystream/delivery-stream-name" ] } }

    完成後,請將檔案儲存為 PinpointEventStreamPermissionsPolicy.json

  4. 使用 put-role-policy 命令將許可政策連接到角色:

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