-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f00dc14
commit 0760f39
Showing
2 changed files
with
134 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
# this manifest creates the database | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: create-setup-user-db | ||
labels: | ||
app: create-setup-user-db | ||
spec: | ||
backoffLimit: 0 | ||
template: | ||
spec: | ||
restartPolicy: Never | ||
containers: | ||
- name: create-setup-user-db | ||
image: amazonlinux:latest | ||
command: | ||
- sh | ||
- -c | ||
- | | ||
/bin/bash <<'EOF' | ||
set -o pipefail | ||
echo "Installing dependencies..." | ||
yum install -y postgresql15 | ||
echo "Create keycloak user and associated database" | ||
psql -h $AURORA_ENDPOINT -p $AURORA_PORT "sslmode=require dbname=$AURORA_DB_NAME user=$AURORA_USERNAME password=$AURORA_PASSWORD" \ | ||
-c "CREATE DATABASE \"${DB_KEYCLOAK_NAME}\";" \ | ||
-c "CREATE USER \"${DB_KEYCLOAK_USERNAME}\" WITH PASSWORD '${DB_KEYCLOAK_PASSWORD}';" \ | ||
-c "GRANT ALL PRIVILEGES ON DATABASE \"${DB_KEYCLOAK_NAME}\" TO \"${DB_KEYCLOAK_USERNAME}\";" | ||
echo "Create identity user and associated database" | ||
psql -h $AURORA_ENDPOINT -p $AURORA_PORT "sslmode=require dbname=$AURORA_DB_NAME user=$AURORA_USERNAME password=$AURORA_PASSWORD" \ | ||
-c "CREATE DATABASE \"${DB_IDENTITY_NAME}\";" \ | ||
-c "CREATE USER \"${DB_IDENTITY_USERNAME}\" WITH PASSWORD '${DB_IDENTITY_PASSWORD}';" \ | ||
-c "GRANT ALL PRIVILEGES ON DATABASE \"${DB_IDENTITY_NAME}\" TO \"${DB_IDENTITY_USERNAME}\";" | ||
echo "Create webmodeler user and associated database" | ||
psql -h $AURORA_ENDPOINT -p $AURORA_PORT "sslmode=require dbname=$AURORA_DB_NAME user=$AURORA_USERNAME password=$AURORA_PASSWORD" \ | ||
-c "CREATE DATABASE \"${DB_WEBMODELER_NAME}\";" \ | ||
-c "CREATE USER \"${DB_WEBMODELER_USERNAME}\" WITH PASSWORD '${DB_WEBMODELER_PASSWORD}';" \ | ||
-c "GRANT ALL PRIVILEGES ON DATABASE \"${DB_WEBMODELER_NAME}\" TO \"${DB_WEBMODELER_USERNAME}\";" | ||
EOF | ||
env: | ||
- name: AURORA_ENDPOINT | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: AURORA_ENDPOINT | ||
- name: AURORA_PORT | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: AURORA_PORT | ||
- name: AURORA_DB_NAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: AURORA_DB_NAME | ||
- name: AURORA_USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: AURORA_USERNAME | ||
- name: AURORA_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: AURORA_PASSWORD | ||
- name: DB_KEYCLOAK_NAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: DB_KEYCLOAK_NAME | ||
- name: DB_KEYCLOAK_USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: DB_KEYCLOAK_USERNAME | ||
- name: DB_KEYCLOAK_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: DB_KEYCLOAK_PASSWORD | ||
- name: DB_IDENTITY_NAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: DB_IDENTITY_NAME | ||
- name: DB_IDENTITY_USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: DB_IDENTITY_USERNAME | ||
- name: DB_IDENTITY_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: DB_IDENTITY_PASSWORD | ||
- name: DB_WEBMODELER_NAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: DB_WEBMODELER_NAME | ||
- name: DB_WEBMODELER_USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: DB_WEBMODELER_USERNAME | ||
- name: DB_WEBMODELER_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: setup-db-secret | ||
key: DB_WEBMODELER_PASSWORD |