Skip to content
Get Help

Scheduled Log Exports Cloud Setup

Last updated

This guide shows you how to set up your own Amazon Web Services (AWS) or Google Cloud Platform (GCP) storage so that Branch can deliver Scheduled Log Exports data to it. For how the API works, see the overview.

Before you begin ​

Make sure you have these.

  • An Access Token: see Credentials. Its owner needs the Export permission and access to Sensitive Data.
  • Permission to create roles and buckets: in the AWS or GCP account that receives the data.

Branch writes the files, deletes the old files in each job's folder before it uploads, and tests your setup when you create the subscription by uploading a small test export of up to 10 rows and then deleting it. So the role or service account needs permission to list, read, create, and delete objects, as the steps below grant.

Cloud configuration ​

Follow the steps for your cloud provider.

Amazon Web Services ​

1. Get your external ID from Branch

Send a request to Get an external ID. Use the same app_id or organization_id that you will use to create the subscription, because each one has its own ID. You need this ID in step 5.

2. Create a bucket and a folder

  1. In S3, create a bucket for your Branch data. Keep it separate from your other buckets, and note its name.
  2. Create a folder in the bucket. The folder name is the prefix that you send when you create the subscription.

3. Create a policy

  1. In the IAM dashboard, go to Policies and select Create policy.

  2. Select the JSON tab, and paste the following. Replace <bucket_name> with your bucket name and <prefix> with your folder name.

    json
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "ListObjectsInBucket",
          "Effect": "Allow",
          "Action": ["s3:ListBucket"],
          "Resource": ["arn:aws:s3:::<bucket_name>"]
        },
        {
          "Sid": "BranchExportsPut",
          "Effect": "Allow",
          "Action": [
            "s3:AbortMultipartUpload",
            "s3:DeleteObject",
            "s3:GetObject",
            "s3:ListBucket",
            "s3:ListBucketMultipartUploads",
            "s3:ListMultipartUploadParts",
            "s3:PutObject"
          ],
          "Resource": ["arn:aws:s3:::<bucket_name>/<prefix>/*"]
        }
      ]
    }
  3. Name the policy, for example branch-scheduled-log-exports, and select Create policy.

4. Create a role

  1. In the IAM dashboard, go to Roles and select Create role.
  2. Choose AWS account as the trusted entity, and select the policy that you created in step 3.
  3. Include Branch-Export-Upload in the role name, for example Branch-Export-Upload-Example. Branch only assumes roles whose name contains that text.
  4. Select Create role, open the new role, and note its ARN. It looks like arn:aws:iam::123456789012:role/Branch-Export-Upload-Example.

5. Let Branch assume the role

  1. On the role, open the Trust relationships tab and select Edit trust policy.

  2. Paste the following. Replace <external_id> with the ID from step 1.

    json
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Principal": {
            "AWS": "arn:aws:iam::772300342379:role/BranchTMRoleProdDataPlatformExports"
          },
          "Action": "sts:AssumeRole",
          "Condition": {
            "StringEquals": {
              "sts:ExternalId": "<external_id>"
            }
          }
        }
      ]
    }

6. Create the subscription

Send a request to Create a subscription with a report object, as in the example, and these destination fields.

  • subscription_type: cloud
  • cloud: s3
  • resource_access_id: the role ARN from step 4
  • bucket: your bucket name
  • prefix: your folder name

7. Check for data

Send a request to Get a subscription until report.subscription_status is ACTIVE. If it's FAILED_VERIFICATION, Branch couldn't write to or delete from your bucket, so check the role name, the trust policy, and the external ID, then create the subscription again.

When jobs run, Branch writes the files in folders inside your prefix. This example is for an hourly subscription.

text
s3://my-branch-export-bucket/my-folder/subscription_id=1d7d7c2e-175b-11ec-9621-0242ac130002/report_type=eo_install/y=2026/m=11/d=17/h=00/

The files use the compression you chose, gz or snappy. Process a folder only after its _SUCCESS file appears.

Google Cloud Platform ​

1. Get your external ID from Branch

Send a request to Get an external ID. Use the same app_id or organization_id that you will use to create the subscription. You need this ID in step 7.

2. Create two custom roles

Predefined bucket roles give more permissions than Branch needs, so create two roles with fewer permissions.

  1. In the IAM & Admin dashboard, go to Roles, and make sure the correct project is selected.
  2. Select Create Role, name it Branch SLE Object List, and add the storage.objects.list permission.
  3. Select Create Role again, name it Branch SLE Upload, and add these permissions.
    • storage.objects.create
    • storage.objects.get
    • storage.objects.delete

3. Create a service account

In the IAM & Admin dashboard, go to Service Accounts, select Create Service Account, and name it, for example branch-sle-service-acct.

4. Let Branch use the service account

  1. Open the new service account and select the Permissions tab.
  2. Select Grant Access, and add gcs-sle-prod-usw1@project-sle-prod.iam.gserviceaccount.com as a principal.
  3. Give that principal the Service Account Token Creator role.

5. Create a bucket and a folder

  1. In Cloud Storage, create a bucket for your Branch data. Keep it separate from your other buckets.
  2. Create a folder in the bucket. The folder name is the prefix that you send when you create the subscription.

6. Give the service account access to the bucket

  1. Open the bucket and select the Permissions tab.
  2. Select Grant Access, and add your service account as a principal.
  3. Assign the Branch SLE Object List and Branch SLE Upload roles.

7. Limit uploads to Branch's folder

Branch writes files under an external_id=<external ID> folder in your prefix. To let the upload role write only there, add a condition to it.

  1. For the Branch SLE Upload role, select Add IAM condition, and give it a title such as Permit SLE Upload to Bucket.

  2. In the Condition Editor tab, enter the following. Replace <YOUR-BUCKET>, <YOUR-PREFIX>, and <YOUR-EXTERNAL-ID> with your bucket name, your folder path, and the ID from step 1.

    javascript
    resource.name.startsWith("projects/_/buckets/<YOUR-BUCKET>/objects/<YOUR-PREFIX>/external_id=<YOUR-EXTERNAL-ID>/")

    For example, for the bucket my-branch-bucket, the prefix branch/important_reports, and the external ID 0a0a0-a0a0a0a-0a0a0a, enter resource.name.startsWith("projects/_/buckets/my-branch-bucket/objects/branch/important_reports/external_id=0a0a0-a0a0a0a-0a0a0a/").

8. Create the subscription

Send a request to Create a subscription with a report object, as in the example, and these destination fields.

  • subscription_type: cloud
  • cloud: gcs
  • resource_access_id: your service account email, for example branch-sle-service-acct@your-sle-project.iam.gserviceaccount.com
  • bucket: your bucket name, for example my-branch-bucket
  • prefix: your folder path, for example branch/important_reports

9. Check for data

Send a request to Get a subscription until report.subscription_status is ACTIVE. If it's FAILED_VERIFICATION, Branch couldn't write to or delete from your bucket, so check the service account roles and the condition, then create the subscription again.

When jobs run, Branch writes the files under <prefix>/external_id=<external ID>/subscription_id=<id>/report_type=<topic>/y=<year>/m=<month>/d=<day>/, plus h=<hour>/ for hourly subscriptions. The files use the compression you chose, gz or snappy. Process a folder only after its _SUCCESS file appears.