|
| 1 | +# AWS S3 |
| 2 | + |
| 3 | +Mixpanel allows you to export events and poeple data into AWS S3 through [Json Pipelines](/docs/data-pipelines/overview) |
| 4 | + |
| 5 | +## Setting S3 Permissions |
| 6 | + |
| 7 | +Before detailing the steps necessary to configure permissions, it's important to note that you need to create your AWS S3 bucket. |
| 8 | + |
| 9 | +Mixpanel supports various configurations to securely manage your data on AWS S3. For resource access, Mixpanel utilizes AWS cross-account roles. This section details the necessary permissions Mixpanel requires based on your S3 bucket configuration. |
| 10 | + |
| 11 | +### Step 1: Create Data Modification Policy |
| 12 | + |
| 13 | +To export data from Mixpanel to AWS S3, assign the following data modification permissions. Use the following policy, replacing `<BUCKET_NAME>` with the name of your bucket: |
| 14 | + |
| 15 | +```json |
| 16 | +{ |
| 17 | + "Version": "2012-10-17", |
| 18 | + "Statement": [ |
| 19 | + { |
| 20 | + "Sid": "MixpanelS3AccessStatement", |
| 21 | + "Effect": "Allow", |
| 22 | + "Action": [ |
| 23 | + "s3:PutObject", |
| 24 | + "s3:GetObject", |
| 25 | + "s3:ListBucket", |
| 26 | + "s3:DeleteObject" |
| 27 | + ], |
| 28 | + "Resource": ["arn:aws:s3:::<BUCKET_NAME>", "arn:aws:s3:::<BUCKET_NAME>/*"] |
| 29 | + } |
| 30 | + ] |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +### Step 2: Server-Side Encryption (optional) |
| 35 | + |
| 36 | +Mixpanel ensures data transfer to your S3 bucket over a TLS encrypted connection. To secure your data at rest in S3, enable [Server-Side Encryption (SSE)](https://docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html), which offers two options: **Encryption with Amazon S3-Managed Keys (SSE-S3)** and **Encryption with AWS KMS-Managed Keys (SSE-KMS)** |
| 37 | + |
| 38 | +#### Encryption with Amazon S3-Managed Keys (SSE-S3) |
| 39 | + |
| 40 | +This option encrypts your data at rest using the AES-256 algorithm, with keys managed by S3. To enable this, select `AES` from the **Encryption** dropdown menu when creating pipelines. |
| 41 | + |
| 42 | +#### Encryption with AWS KMS-Managed Keys (SSE-KMS) |
| 43 | + |
| 44 | +For encryption with AWS KMS, you have the option to use either the default `aws/s3` key or your own custom keys. |
| 45 | + |
| 46 | +- Using the Default Key |
| 47 | + |
| 48 | + Simply select `KMS` from the **Encryption** dropdown menu and leave the `KMS Key ID` field empty when creating your pipeline. |
| 49 | + |
| 50 | +- Using Custom Key |
| 51 | + |
| 52 | + 1. Select `KMS` from the **Encryption** dropdown menu and enter your custom key's ARN in the `KMS Key ID` field. |
| 53 | + |
| 54 | + 2. Create an IAM policy allowing Mixpanel to use your KMS key, as shown in the JSON snippet below. Replace `<KEY_ARN>` with your key's ARN: |
| 55 | + |
| 56 | + ```json |
| 57 | + { |
| 58 | + "Version": "2012-10-17", |
| 59 | + "Statement": [ |
| 60 | + { |
| 61 | + "Sid": "MixpanelKmsStatement", |
| 62 | + "Effect": "Allow", |
| 63 | + "Action": [ |
| 64 | + "kms:Decrypt", |
| 65 | + "kms:Encrypt", |
| 66 | + "kms:GenerateDataKey", |
| 67 | + "kms:ReEncryptTo", |
| 68 | + "kms:GenerateDataKeyWithoutPlaintext", |
| 69 | + "kms:DescribeKey", |
| 70 | + "kms:ReEncryptFrom" |
| 71 | + ], |
| 72 | + "Resource": "<KEY_ARN>" |
| 73 | + } |
| 74 | + ] |
| 75 | + } |
| 76 | + ``` |
| 77 | + |
| 78 | +### Step 3: Create Access Role |
| 79 | + |
| 80 | +After establishing the necessary policies, create a cross-account IAM Role to attach policies you've created: |
| 81 | + |
| 82 | +- Go to the **IAM** service on the AWS console. |
| 83 | +- Select **Roles** in the sidebar and click **Create role**. |
| 84 | +- On the trusted entity page, choose **AWS Account**, then click **Another AWS account**, and enter `485438090326` for the **Account ID** and click **Next**. |
| 85 | +- On the permissions page, locate and attach the policies you created in previous steps (data modification and, if appliable, KMS). |
| 86 | +- On the review page, provide a name and description for this role and click **Create role**. |
| 87 | + |
| 88 | +To ensure secure operations, limit the trust relationship to the Mixpanel export user: |
| 89 | + |
| 90 | +- Return to the **IAM** service, select **Roles**, and locate the role you just created. |
| 91 | +- In the **Trust relationships** tab, click **Edit trust policy**. |
| 92 | +- Update the trust relationship with the following JSON, replacing `<MIXPANEL_PROJECT_TOKEN>` with your Mixpanel project token. |
| 93 | + |
| 94 | + ```json |
| 95 | + { |
| 96 | + "Version": "2012-10-17", |
| 97 | + "Statement": [ |
| 98 | + { |
| 99 | + "Effect": "Allow", |
| 100 | + "Principal": { |
| 101 | + "AWS": "arn:aws:iam::485438090326:user/mixpanel-export" |
| 102 | + }, |
| 103 | + "Action": "sts:AssumeRole", |
| 104 | + "Condition": { |
| 105 | + "StringEquals": { |
| 106 | + "sts:ExternalId": "<MIXPANEL_PROJECT_TOKEN>" |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + ] |
| 111 | + } |
| 112 | + ``` |
| 113 | + |
| 114 | +- Click **Update policy** and save. |
| 115 | + |
| 116 | +This setup utilizes an external ID to prevent [the confused deputy problem](https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html), enhancing the security of cross-account access as Mixpanel interacts with AWS using your project token. |
| 117 | + |
| 118 | +### Step 4: Provide Mixpanel with S3 Details |
| 119 | + |
| 120 | +Refer to [Step 2: Creating the Pipeline](/docs/data-pipelines/overview/#step-2-creating-the-pipeline) |
| 121 | +to create data pipeline via UI. It is essential to provide specific details to ensure that Mixpanel can accurately direct the data exports to your S3 bucket: |
| 122 | + |
| 123 | +- **Bucket**: Specify the S3 bucket where Mixpanel data should be exported. |
| 124 | +- **Region**: Indicate the AWS region where your S3 bucket is located. |
| 125 | +- **Role**: Provide the AWS Role ARN that Mixpanel should assume when writing to your S3, e.g., `arn:aws:iam:::role/example-s3-role`. |
| 126 | +- **Encryption (optional)**: Specify the type of at-rest encryption used by the S3 bucket. |
| 127 | +- **KMS Key ID (optional)**: If using KMS encryption, you can provide the custom key ID that you wish to use. |
0 commit comments