Objective
The steps below will walk you through the process of connecting BigQuery to Segment as a source, along with the prerequisites.
Product
Twilio Segment
Environment
Segment Console
Procedure
The steps to setup your BigQuery source with Reverse ETL are:
- Construct a BigQuery role and service account.
- Create a BigQuery source in your Segment workspace.
Construct a BigQuery role and service account.
You can provide Segment access to your BigQuery resources in two ways:
Grant Full Access
- In BigQuery, navigate to IAM & Admin > Service Accounts.
- Click + Create Service Account to create a new service account.
- Enter your Service account name and a description of what the service account will do.
- Click Create and Continue.
- Click + Add another role and add the BigQuery User role.
- Click + Add another role and add the BigQuery Data Editor role.
- Click Continue, then click Done.
Grant Limited Access
- In BigQuery, navigate to IAM & Admin > Roles.
- Click + CREATE ROLE to create a new role.
- Add Title and Description as you like.
- Click ADD PERMISSIONS and add the permission listed in the above tables. Repeat this step until you’ve added all required permissions.
- Click CREATE.
- Navigate to IAM & Admin > Service Accounts.
- Click + Create Service Account to create a new service account.
- Enter your Service account name and a description of what the account will do.
- Click Create and Continue.
- In the Grant this service account access to project section, select the role you just created.
- Click Continue.
- Click Done. Copy and keep the Service Account email handy for the next steps.
-
Navigate to the BigQuery SQL editor and create a dataset that will be used by Segment:
CREATE SCHEMA IF NOT EXISTS `__segment_reverse_etl`;
-
Grant limited access to the Segment Reverse ETL dataset
GRANT `roles/bigquery.dataEditor` ON SCHEMA `__segment_reverse_etl` TO "serviceAccount:<YOUR SERVICE ACCOUNT EMAIL>";
Create a BigQuery source in your Segment workspace
- In the BigQuery console, search for the service account you created.
- When your service account pulls up, click the 3 dots under Actions and select Manage keys.
- Click Add Key > Create new key.
- In the pop-up window, select JSON for the key type and click Create. The file will be downloaded.
- Copy all the content in the JSON file you created in the previous step.
- Open the Segment app and navigate to Connections > Sources.
- On the My sources page, click + Add source.
- Search for “BigQuery” and select the BigQuery source from the sources catalog. On the BigQuery overview page, click Add Source.
- On the Set up BigQuery page, enter a name for your source and paste all the credentials you copied from previous step into the Enter your credentials section.
- Enter the location of your BigQuery warehouse in the Data Location field.
- Click Test Connection to test to see if the connection works. If the connection fails, make sure you have the right permissions and credentials and try again.
- If the test connection completes successfully, click Add source to complete the setup process.
Additional Information
More information on setting up BigQuery as your Reverse ETL source can be found here.