electric-sql / electric-sql/pglite

CREATE ROLE electric permissions

Open
#768 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16k
Forks
442
Avg merge
20h 19m
Merged PRs (30d)
7

Description

Our primary user has auto-rotation for its password [docs.aws.amazon.com/secretsmanager/latest/userguide/rotate-secrets_turn-on-for-db.html](https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotate-secrets_turn-on-for-db.html). We want to create another role with a static password with the minimal permissions needed, however I don't see a guide on how to do this or what permissions would be needed.

Would you be able to point me in the right direction? unsure if this goes here or in electric.

```
DO $$
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
pg_roles
WHERE
rolname = 'zeus') THEN
CREATE ROLE zeus LOGIN CONNECTION LIMIT 100;
GRANT rds_replication TO zeus;
ELSE
ALTER ROLE zeus LOGIN CONNECTION LIMIT 100;
GRANT rds_replication TO zeus;
END IF;
END
$$;

-- DB connect (idempotent)
GRANT CONNECT ON DATABASE postgres TO zeus;

-- Run the following in the "postgres" database if you actually want table reads:
GRANT USAGE ON SCHEMA public TO zeus;

GRANT SELECT ON ALL TABLES IN SCHEMA public TO zeus;

ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT
SELECT
ON TABLES TO zeus;

```

this is the general direction we went for the user. let me know if there are issues please!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.