|
| 1 | +--- |
| 2 | +title: Redshift Setup |
| 3 | +beta: true |
| 4 | +plan: unify |
| 5 | +--- |
| 6 | + |
| 7 | +On this page, you'll learn how to connect your Redshift data warehouse to Segment. |
| 8 | + |
| 9 | +## Getting started |
| 10 | + |
| 11 | +To get started with Redshift: |
| 12 | +1. Log in to Redshift and select the Redshift cluster you want to connect. |
| 13 | +2. Follow [these instructions](/docs/connections/storage/catalog/redshift/#networking) to configure the correct network and security settings. |
| 14 | + |
| 15 | +## Create a new role and user |
| 16 | + |
| 17 | +Run the SQL commands below to create a role <segment_entities> and user <segment_entities_user>. |
| 18 | + |
| 19 | +```sql |
| 20 | +-- create role |
| 21 | +CREATE ROLE segment_entities; |
| 22 | + |
| 23 | +-- allow the role to create new schemas on specified database. (This is the name you chose when provisioning your cluster) |
| 24 | +GRANT CREATE ON DATABASE "<enter database name here>" TO ROLE segment_entities; |
| 25 | + |
| 26 | +-- create a user named "segment_entities_user" that Segment will use when connecting to your Redshift cluster. |
| 27 | +CREATE USER segment_entities_user PASSWORD '<enter password here>'; |
| 28 | + |
| 29 | +-- grant role permissions to the user |
| 30 | +GRANT ROLE segment_entities TO segment_entities_user; |
| 31 | +``` |
| 32 | + |
| 33 | +## Grant access to schemas and tables |
| 34 | + |
| 35 | +You'll need to grant access to schemas and tables that you'd like to enrich with. This allows Segment to list schemas, tables, and columns, as well as create entities with data extracted and ingested to Segment |
| 36 | + |
| 37 | +### Schemas |
| 38 | + |
| 39 | +Grant schema permissions based on customer need. View Amazon's docs for more on [schema permissions](https://docs.aws.amazon.com/redshift/latest/dg/r_GRANT.html){:target="_blank"} and to view some [example commands](https://docs.aws.amazon.com/redshift/latest/dg/r_GRANT-examples.html){:target="_blank"} that you can use to grant permissions. |
| 40 | + |
| 41 | +```sql |
| 42 | +-- view specific schemas in database |
| 43 | +GRANT USAGE ON SCHEMA <schema-name> TO ROLE segment_entities; |
| 44 | +``` |
| 45 | + |
| 46 | +### Tables |
| 47 | + |
| 48 | +Grant table permissions based on customer need. View descriptions of table permissions in [Amazon's docs](https://docs.aws.amazon.com/redshift/latest/dg/r_GRANT.html){:target="_blank"}. |
| 49 | + |
| 50 | +```sql |
| 51 | +-- query data from a specific table in a schema |
| 52 | +GRANT SELECT ON TABLE <schema-name>.<table-name> TO ROLE segment_entities; |
| 53 | +``` |
| 54 | + |
| 55 | +## Grant access to Reverse ETL |
| 56 | + |
| 57 | +Run the SQL commands below if RETL has ever run in your database and you add a new user. |
| 58 | + |
| 59 | +```sql |
| 60 | +GRANT USAGE, CREATE ON SCHEMA __segment_reverse_etl TO ROLE segment_entities; |
| 61 | + |
| 62 | +GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA __segment_reverse_etl TO ROLE segment_entities; |
| 63 | +``` |
0 commit comments