Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sentry database config from AWS RDS secrets #1339

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ WAL2JSON_VERSION=latest
HEALTHCHECK_INTERVAL=30s
HEALTHCHECK_TIMEOUT=60s
HEALTHCHECK_RETRIES=5

# AWS specific settings
AWS_RDS_SECRET_NAME = ""
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ x-sentry-defaults: &sentry_defaults
# on the host system (or in the .env file)
SENTRY_EVENT_RETENTION_DAYS:
SENTRY_MAIL_HOST:
AWS_RDS_SECRET_NAME:
volumes:
- "sentry-data:/data"
- "./sentry:/etc/sentry"
Expand Down
1 change: 1 addition & 0 deletions sentry/requirements.example.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Add plugins here
boto3==1.21.4
22 changes: 17 additions & 5 deletions sentry/sentry.conf.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# you can inherit and tweak settings to your hearts content.

from sentry.conf.server import * # NOQA
import boto3


# Generously adapted from pynetlinux: https://git.io/JJmga
Expand Down Expand Up @@ -33,14 +34,25 @@ def get_internal_network():
INTERNAL_SYSTEM_IPS = (get_internal_network(),)


def get_db_secret_from_secrets_manager(secret_name, region_name="eu-west-1"):
session = boto3.session.Session()
client = session.client(
service_name="secretsmanager",
region_name=region_name,
)
return client.get_secret_value(SecretId=secret_name)


db_secret = get_db_secret_from_secrets_manager(env("AWS_RDS_SECRET_NAME"))

DATABASES = {
"default": {
"ENGINE": "sentry.db.postgres",
"NAME": "postgres",
"USER": "postgres",
"PASSWORD": "",
"HOST": "postgres",
"PORT": "",
"NAME": db_secret["dbname"],
"USER": db_secret["username"],
"PASSWORD": db_secret["password"],
"HOST": db_secret["host"],
"PORT": db_secret["port"],
}
}

Expand Down