Skip to content

Commit

Permalink
Enhance postgres init scripts and interior cf tunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
neoxelox committed Sep 9, 2024
1 parent 5ccd79d commit 0a10aca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
7 changes: 5 additions & 2 deletions envs/ci/postgres-init.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
set -eo pipefail

psql -U ${POSTGRES_USER} <<-END
-- SUPERUSER is needed to create extensions. Remember to revoke it when not needed!
CREATE USER ${SERVICE_DATABASE_USER} WITH
CREATEROLE
SUPERUSER
PASSWORD '${SERVICE_DATABASE_PASSWORD}';
Expand All @@ -16,11 +17,13 @@ CREATE DATABASE ${SERVICE_DATABASE_NAME}_TEST WITH
CREATE USER ${SERVICE_DATABASE_READONLY_USER} WITH
PASSWORD '${SERVICE_DATABASE_READONLY_PASSWORD}';
\c ${SERVICE_DATABASE_NAME}
GRANT CONNECT ON DATABASE ${SERVICE_DATABASE_NAME} TO ${SERVICE_DATABASE_READONLY_USER};
GRANT USAGE ON SCHEMA public TO ${SERVICE_DATABASE_READONLY_USER};
ALTER DEFAULT PRIVILEGES FOR USER ${SERVICE_DATABASE_USER} IN SCHEMA public
GRANT SELECT ON TABLES TO ${SERVICE_DATABASE_READONLY_USER};
END
END
7 changes: 5 additions & 2 deletions envs/dev/postgres-init.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
set -eo pipefail

psql -U ${POSTGRES_USER} <<-END
-- SUPERUSER is needed to create extensions. Remember to revoke it when not needed!
CREATE USER ${SERVICE_DATABASE_USER} WITH
CREATEROLE
SUPERUSER
PASSWORD '${SERVICE_DATABASE_PASSWORD}';
Expand All @@ -16,11 +17,13 @@ CREATE DATABASE ${SERVICE_DATABASE_NAME}_TEST WITH
CREATE USER ${SERVICE_DATABASE_READONLY_USER} WITH
PASSWORD '${SERVICE_DATABASE_READONLY_PASSWORD}';
\c ${SERVICE_DATABASE_NAME}
GRANT CONNECT ON DATABASE ${SERVICE_DATABASE_NAME} TO ${SERVICE_DATABASE_READONLY_USER};
GRANT USAGE ON SCHEMA public TO ${SERVICE_DATABASE_READONLY_USER};
ALTER DEFAULT PRIVILEGES FOR USER ${SERVICE_DATABASE_USER} IN SCHEMA public
GRANT SELECT ON TABLES TO ${SERVICE_DATABASE_READONLY_USER};
END
END
7 changes: 7 additions & 0 deletions envs/prod/cloudflared-int.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
tunnel:
credentials-file: /etc/cloudflared/certs/.json
originRequest:
access:
required: true
teamName:
audTag:
- ... # Metabase
- ... # Asynqmon

ingress:
- hostname: api.
Expand Down
7 changes: 5 additions & 2 deletions envs/prod/postgres-init.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
set -eo pipefail

psql -U ${POSTGRES_USER} <<-END
-- SUPERUSER is needed to create extensions. Remember to revoke it when not needed!
CREATE USER ${SERVICE_DATABASE_USER} WITH
CREATEROLE
SUPERUSER
PASSWORD '${SERVICE_DATABASE_PASSWORD}';
Expand All @@ -16,11 +17,13 @@ CREATE DATABASE ${SERVICE_DATABASE_NAME}_TEST WITH
CREATE USER ${SERVICE_DATABASE_READONLY_USER} WITH
PASSWORD '${SERVICE_DATABASE_READONLY_PASSWORD}';
\c ${SERVICE_DATABASE_NAME}
GRANT CONNECT ON DATABASE ${SERVICE_DATABASE_NAME} TO ${SERVICE_DATABASE_READONLY_USER};
GRANT USAGE ON SCHEMA public TO ${SERVICE_DATABASE_READONLY_USER};
ALTER DEFAULT PRIVILEGES FOR USER ${SERVICE_DATABASE_USER} IN SCHEMA public
GRANT SELECT ON TABLES TO ${SERVICE_DATABASE_READONLY_USER};
END
END

0 comments on commit 0a10aca

Please sign in to comment.