Skip to content

Commit

Permalink
get_profile_creation_query: add query history permissions to redshift (
Browse files Browse the repository at this point in the history
  • Loading branch information
haritamar authored Nov 7, 2023
1 parent 2b33147 commit 5d52438
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions macros/utils/cross_db_utils/get_profile_creation_query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,26 @@ CALL GRANT_MONITOR_ON_ALL_WAREHOUSES('{{ parameters["role"] }}');
{% endmacro %}


{% macro redshift__get_profile_creation_query(parameters) %}
-- Create redshift user with unrestricted access to query history (allows Elementary to see queries generated by
-- any user)
CREATE USER {{ parameters["user"] }} WITH PASSWORD '{{ parameters["password"] }}' SYSLOG ACCESS UNRESTRICTED;

-- Grant read access to the Elementary schema
GRANT USAGE ON SCHEMA {{ parameters["schema"] }} TO {{ parameters["user"] }};
GRANT SELECT ON ALL TABLES IN SCHEMA {{ parameters["schema"] }} TO {{ parameters["user"] }};
ALTER DEFAULT PRIVILEGES IN SCHEMA {{ parameters["schema"] }} GRANT SELECT ON TABLES TO {{ parameters["user"] }};

-- Grant metadata access to tables in the warehouse
GRANT SELECT ON svv_table_info to {{ parameters["user"] }};
{% endmacro %}


{% macro postgres__get_profile_creation_query(parameters) %}
-- Create postgres user
CREATE USER {{ parameters["user"] }} WITH PASSWORD '{{ parameters["password"] }}';

-- Grant read access to the Elementary schema
GRANT USAGE ON SCHEMA {{ parameters["schema"] }} TO {{ parameters["user"] }};
GRANT SELECT ON ALL TABLES IN SCHEMA {{ parameters["schema"] }} TO {{ parameters["user"] }};
ALTER DEFAULT PRIVILEGES IN SCHEMA {{ parameters["schema"] }} GRANT SELECT ON TABLES TO {{ parameters["user"] }};
Expand Down

0 comments on commit 5d52438

Please sign in to comment.