Menu
Amazon Pinpoint
Developer Guide

IAM Role for Exporting Events to Amazon S3

Amazon Pinpoint can automatically export analytics data, or event data, from your app to an Amazon S3 bucket in your AWS account. Before you export the event data, you must delegate the required permissions to Amazon Pinpoint. Create an AWS Identity and Access Management (IAM) role and attach the following policies to the role:

  • A permissions policy that allows Amazon Pinpoint to add event data to your Amazon S3 bucket.

  • A trust policy that allows Amazon Pinpoint to assume the role.

For more information about IAM roles, see IAM Roles in the IAM User Guide.

After you create the role, you can export event data by setting up event streaming in the Amazon Pinpoint console. For more information, see Exporting Amazon Pinpoint Events to Amazon S3 in the Amazon Pinpoint User Guide.

Permissions Policy

To allow Amazon Pinpoint to add event data to your Amazon S3 bucket, attach the following permissions policy to the role:

Copy
{ "Statement": [ { "Resource": "arn:aws:s3:::your-bucket-name/*", "Action": [ "s3:PutObject", "s3:PutObjectAcl", "s3:PutObjectVersionAcl" ], "Effect": "Allow" } ], "Version": "2012-10-17" }

Replace your-bucket-name with the name of the Amazon S3 bucket to which you want to export the event data.

Trust Policy

To allow Amazon Pinpoint to assume the IAM role and perform the actions allowed by the permissions policy, attach the following trust policy to the role:

Copy
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "mobileanalytics.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }

Creating the IAM Role (AWS CLI)

Complete the following steps to create the IAM role by using the AWS Command Line Interface (AWS CLI).

If you have not installed the AWS CLI, see Getting Set Up with the AWS Command Line Interface in the AWS Command Line Interface User Guide.

To create the role by using the IAM console, see Setting up Automatic Exports to Amazon S3 in the Amazon Pinpoint User Guide.

To create the IAM role by using the AWS CLI

  1. Create a JSON file that contains the trust policy for your role, and save the file locally. You can copy the trust policy provided in this topic.

  2. Use the create-role command to create the role and attach the trust policy:

    Copy
    aws iam create-role --role-name PinpointAnalyticsExport --assume-role-policy-document file://PinpointExportTrustPolicy.json

    Following the file:// prefix, specify the path to the JSON file that contains the trust policy.

    When you run this command, the AWS CLI prints the following output in your terminal:

    Copy
    { "Role": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:root" } } ] }, "RoleId": "AIDACKCEVSQ6C2EXAMPLE", "CreateDate": "2016-12-20T18:02:48.220Z", "RoleName": "PinpointAutoExport", "Path": "/", "Arn": "arn:aws:iam::111122223333:role/PinpointAutoExport" } }
  3. Create a JSON file that contains the permissions policy for your role, and save the file locally. You can copy the permissions policy provided in this topic.

  4. Use the put-role-policy command to attach the permissions policy to the role:

    Copy
    aws iam put-role-policy --role-name PinpointAutoExport --policy-name PinpointExportPermissionsPolicy --policy-document file://PinpointExportPermissionsPolicy.json

    Following the file:// prefix, specify the path to the JSON file that contains the permissions policy.