Skip to content

Commit 5915111

Browse files
committed
Redshift DG User Permission [netlify-build]
1 parent b7ee9e8 commit 5915111

File tree

2 files changed

+201
-0
lines changed

2 files changed

+201
-0
lines changed

src/_data/sidenav/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ sections:
362362
title: Databricks Data Graph Setup
363363
- path: /unify/data-graph/setup-guides/redshift-setup/
364364
title: Redshift Data Graph Setup
365+
- path: /unify/data-graph/setup-guides/redshift-access-permissions/
366+
title: Redshift Data Graph User Access Permissions
365367
- path: /unify/data-graph/setup-guides/snowflake-setup/
366368
title: Snowflake Data Graph Setup
367369
- section_title: Linked Events
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
---
2+
title: Redshift Data Graph User Access Permissions
3+
---
4+
5+
You can set up the Data Graph in such a way that Segment has access to 2 databases:
6+
* The first database has write access for storing Reverse ETL checkpoints databases
7+
* The second database has read access
8+
9+
## Permissions Option 1
10+
11+
### Database
12+
Create a separate databse for Segment usage (for example, `segment_workspace`). This will have the following schemas:
13+
1. Profiles Sync Schema (for example: `profiles_sync`)
14+
* Segment will add [Profiles Sync tables](/docs/unify/profiles-sync/tables/) to this schema
15+
2. `__segment_reverse_etl` schema
16+
* Segment will create the [`__segment_reverse_etl` schema](/docs/connections/reverse-etl/system/#reverse-etl-schema) to add checksum tables for Linked/Data Graph
17+
18+
### User
19+
Have 2 roles assigned to the Segment user:
20+
* Profiles Sync role (for example, `segment_profiles_sync_role`)
21+
* Linked/Data Graph role (for example, `segment_linked_role`)
22+
23+
### Roles
24+
#### Profiles Sync role (`segment_profiles_sync_role`)
25+
The profiles sync role has the following permissions:
26+
* Read and write access to the Profiles Sync schema (for example, `profiles_sync`)
27+
28+
#### Linked/Data Graph role (`segment_linked_role`)
29+
This role has the following permissions:
30+
* Write access to the Segment Database (for example, `segment_workspace`) to create the `__segment_reverse_etl` schema in it
31+
* Read access to Profiles Sync schema (for example, `profiles_sync`) to read Segment Profile and Event tables that are created by Profiles Sync
32+
* Read access to full user data schema (for example, devices schema), or read access to specific tables in the user data schema (for example, `user_devices` table or `device_locations` table)
33+
34+
## Permissions Option 2
35+
36+
### Database
37+
Create a single database for Profiles Sync & Linked usage (for example, `segment_workspace`). This has the following schemas:
38+
1. Profiles Sync schema (for example, profiles_sync)
39+
* Segment adds [Profiles Sync tables](/docs/unify/profiles-sync/tables/) to this schema
40+
2. `__segment_reverse_etl` schema
41+
* Segment creates the [`__segment_reverse_etl` schema](/docs/connections/reverse-etl/system/#reverse-etl-schema) to add checksum tables for Linked/Data Graph
42+
3. End User Entity Details schema (for example, devices)
43+
* Segment has read access to these tables
44+
45+
### User
46+
Have these 2 roles assigned to the Segment user:
47+
* Profiles Sync role (for example, `segment_profiles_sync_role`)
48+
* Linked/Data Graph role (for example, `segment_linked_role`)
49+
50+
### Roles
51+
#### Profiles Sync role (`segment_profiles_sync_role`)
52+
53+
This role has the following permissions:
54+
* Read and write access to the Profiles Sync schema (for example, `profiles_sync`)
55+
56+
#### Linked/Data Graph role (segment_linked_role)
57+
This role has the following permissions:
58+
* Write access to Database (for example, `segment_workspace`) to create the `__segment_reverse_etl` schema in it
59+
* Read access to Profiles Sync schema (for example, `profiles_sync`) to read Segment Profile/Event tables that are created by Profiles Sync
60+
* Read access to full user data schema (for example, devices schema) or read access to specific tables in the user data schema (for example, `user_devices` table or `device_locations` table)
61+
62+
## Setup Guide
63+
To set your Data Graph so that Segment has access to 2 databases within your Redshift Cluster:
64+
65+
### Step 1: Create the new Segment database
66+
Run:
67+
68+
```
69+
--Create new Segment database
70+
CREATE DATABASE segment_workspace;
71+
```
72+
73+
### Step 2: Create the Profiles Sync role
74+
75+
1. Switch to the Segment database in the Redshift query editor. Create a new Profiles Sync role.
76+
77+
```
78+
--create new Profiles Sync role
79+
CREATE ROLE segment_profiles_sync_role;
80+
```
81+
82+
2. Create a new Profiles Sync schema.
83+
84+
```
85+
--create new Profiles Sync schema
86+
CREATE SCHEMA "profiles_sync";
87+
```
88+
89+
3. Assign the Profiles Sync role with read and write access to the Profiles Sync schema.
90+
91+
```
92+
--grant Profiles Sync role write access to Profiles Sync schema
93+
GRANT ALL ON SCHEMA profiles_sync TO ROLE segment_profiles_sync_role;
94+
```
95+
96+
### Step 3: Create the Linked/Data Graph role
97+
98+
1. Create a new Linked/Data Graph role.
99+
100+
```
101+
--create new Linked/Data Graph role
102+
CREATE ROLE segment_linked_role;
103+
```
104+
105+
2. Assign the Linked/Data Graph role with write access to the Segment database ([created in Step 1](#step-1-create-the-new-segment-database)) for permissions to create a new `__segment_reverse_etl` schema.
106+
107+
```
108+
--grant Linked role write access to segment_workspace DATABASE to create __segment_reverse_etl SCHEMA
109+
GRANT CREATE ON DATABASE segment_workspace TO ROLE segment_linked_role;
110+
```
111+
112+
3. Assign the Linked/Data Graph role with read access to the Profiles Sync schema to access the Segment Profile/Event data.
113+
114+
```
115+
--grant Linked role read access to Profiles Sync SCHEMA
116+
GRANT USAGE ON SCHEMA "profiles_sync" TO ROLE segment_linked_role;
117+
118+
-- Grant read access to existing Profiles Sync tables
119+
GRANT SELECT ON ALL TABLES IN SCHEMA profiles_sync TO ROLE segment_linked_role;
120+
121+
-- Ensure future Profiles Sync tables also allow read access
122+
ALTER DEFAULT PRIVILEGES IN SCHEMA profiles_sync
123+
GRANT SELECT ON TABLES TO ROLE segment_linked_role;
124+
```
125+
126+
4. Assign the Linked/Data Graph role read access to end user Entity Data.
127+
* For [Permissions Option 1](#permissions-option-1):
128+
1. Switch to the end user database in the query editor. Assign the Linked/Data Graph role with read access to user data.
129+
130+
```
131+
--grant Linked role read access to user entity tables in DATABASE user_database
132+
GRANT USAGE ON SCHEMA devices TO ROLE segment_linked_role;
133+
```
134+
135+
2. Select 1 of the options below:
136+
137+
a. (*Option 1*):: Assign the Linked/Data Graph role with read access to full user data schema
138+
139+
```
140+
--for access to the full devices SCHEMA
141+
GRANT SELECT ON ALL TABLES IN SCHEMA devices TO ROLE segment_linked_role;
142+
143+
--ensure future user tables also allow read access
144+
ALTER DEFAULT PRIVILEGES IN SCHEMA devices
145+
GRANT SELECT ON TABLES TO ROLE segment_linked_role;
146+
```
147+
148+
b. (*Option 2*): Assign the Linked/Data Graph role with read access to specific tables in the user data schema
149+
150+
```
151+
--for access to select tables in the devices SCHEMA
152+
GRANT SELECT ON devices.user_devices TO ROLE segment_linked_role;
153+
GRANT SELECT ON devices.device_locations TO ROLE segment_linked_role;
154+
```
155+
* For permissions option 2:
156+
1. Stay in the Segment Database within the Redshift Query Editor. Assign the Linked/Data Graph role with read access to user data.
157+
158+
```
159+
--grant Linked role read access to user entity tables in DATABASE segment_workspace
160+
GRANT USAGE ON SCHEMA devices TO ROLE segment_linked_role;
161+
```
162+
163+
2. Select 1 of the options:
164+
165+
a. (*Option 1*): Assign the Linked/Data Graph role with read access to the full user data schema.
166+
167+
```
168+
--for access to the full devices SCHEMA
169+
GRANT SELECT ON ALL TABLES IN SCHEMA devices TO ROLE segment_linked_role;
170+
171+
--ensure future user tables also allow read access
172+
ALTER DEFAULT PRIVILEGES IN SCHEMA devices
173+
GRANT SELECT ON TABLES TO ROLE segment_linked_role;
174+
```
175+
176+
b. (*Option 2*): Assign the Linked/Data Graph role with read access to specific tables in the user data schema
177+
178+
```
179+
--for access to select tables in the devices SCHEMA
180+
GRANT SELECT ON devices.user_devices TO ROLE segment_linked_role;
181+
GRANT SELECT ON devices.device_locations TO ROLE segment_linked_role;
182+
```
183+
184+
### Step 4: Create a new Segment user
185+
1. Switch back to the Segment database in the query editor.
186+
187+
```
188+
--create new USER
189+
CREATE USER segment_user PASSWORD 'Abc123';
190+
```
191+
192+
### Step 5: Assign both the Profiles Sync role ([from Step 2](#step-2-create-the-profiles-sync-role)) and the Linked/Data Graph role (from [Step 3](#step-3-create-the-linkeddata-graph-role)) to the user
193+
194+
```
195+
--assign both roles to USER
196+
GRANT ROLE segment_profiles_sync_role TO segment_user; --Assign Profiles Sync Role to user
197+
GRANT ROLE segment_linked_role TO segment_user; --Assign Linked/Data Graph Role to user
198+
```
199+

0 commit comments

Comments
 (0)