Skip to content

Commit

Permalink
fix: remove manual cloud SQL proxy installation
Browse files Browse the repository at this point in the history
  • Loading branch information
ngurenyaga committed Jul 12, 2021
1 parent ca0c124 commit b351ad1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
7 changes: 7 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@
APPS_DIR = ROOT_DIR / "pepfar_mle"
env = environ.Env()

# >>> from urllib.parse import quote_plus
# >>> host = '/cloudsql/sghi-307909:europe-west1:clinical-instance'
# >>> quote_plus(host)
# '%2Fcloudsql%2Fsghi-307909%3Aeurope-west1%3Aclinical-instance'
# >>>
if os.environ.get("GOOGLE_CLOUD_PROJECT", None):
project_id = os.environ.get("GOOGLE_CLOUD_PROJECT")
client = secretmanager.SecretManagerServiceClient()
settings_name = os.environ.get("SETTINGS_NAME", "mle_django_settings")
name = f"projects/{project_id}/secrets/{settings_name}/versions/latest"
payload = client.access_secret_version(name=name).payload.data.decode("UTF-8")
env.read_env(io.StringIO(payload))
print("set env from secrets...")
print(f'database settings: {env.db("DATABASE_URL")}')

# GENERAL
# ------------------------------------------------------------------------------
Expand Down
5 changes: 0 additions & 5 deletions entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ set -o errexit
set -o pipefail
set -o nounset

# run in the background and allow it some time to start before continuing
/app/cloud_sql_proxy -verbose -structured_logs -dir=/cloudsql -instances=$INSTANCE_CONNECTION_NAME &
sleep 10
echo "Created Cloud SQL Proxy at $INSTANCE_CONNECTION_NAME, running in the background"

if [ -z "${POSTGRES_USER}" ]; then
base_postgres_image_default_user='postgres'
export POSTGRES_USER="${base_postgres_image_default_user}"
Expand Down
12 changes: 0 additions & 12 deletions install_cloudsql_proxy.sh

This file was deleted.

0 comments on commit b351ad1

Please sign in to comment.