Skip to content

Commit

Permalink
Load secret value as json
Browse files Browse the repository at this point in the history
  • Loading branch information
Glyphack committed Mar 7, 2022
1 parent 1078cbf commit ef92033
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions sentry/sentry.conf.example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file is just Python, with a touch of Django which means
# you can inherit and tweak settings to your hearts content.
import json

from sentry.conf.server import * # NOQA
import boto3
Expand All @@ -19,15 +20,20 @@ def get_internal_network():

try:
ip = struct.unpack(
b"!I", struct.unpack(b"16sH2x4s8x", fcntl.ioctl(sockfd, 0x8915, ifreq))[2]
b"!I",
struct.unpack(b"16sH2x4s8x", fcntl.ioctl(sockfd, 0x8915, ifreq))[
2
],
)[0]
netmask = socket.ntohl(
struct.unpack(b"16sH2xI8x", fcntl.ioctl(sockfd, 0x891B, ifreq))[2]
)
except IOError:
return ()
base = socket.inet_ntoa(struct.pack(b"!I", ip & netmask))
netmask_bits = 32 - int(round(math.log(ctypes.c_uint32(~netmask).value + 1, 2), 1))
netmask_bits = 32 - int(
round(math.log(ctypes.c_uint32(~netmask).value + 1, 2), 1)
)
return "{0:s}/{1:d}".format(base, netmask_bits)


Expand All @@ -40,7 +46,9 @@ def get_db_secret_from_secrets_manager(secret_name, region_name="eu-west-1"):
service_name="secretsmanager",
region_name=region_name,
)
return client.get_secret_value(SecretId=secret_name)
response = client.get_secret_value(SecretId=secret_name)
secret_json = json.loads(response["SecretString"])
return secret_json


db_secret = get_db_secret_from_secrets_manager(env("AWS_RDS_SECRET_NAME"))
Expand Down Expand Up @@ -84,7 +92,9 @@ def get_db_secret_from_secrets_manager(secret_name, region_name="eu-west-1"):

SENTRY_OPTIONS["redis.clusters"] = {
"default": {
"hosts": {0: {"host": "redis", "password": "", "port": "6379", "db": "0"}}
"hosts": {
0: {"host": "redis", "password": "", "port": "6379", "db": "0"}
}
}
}

Expand Down Expand Up @@ -244,7 +254,7 @@ def get_db_secret_from_secrets_manager(secret_name, region_name="eu-west-1"):
# Mail #
########

SENTRY_OPTIONS["mail.list-namespace"] = env('SENTRY_MAIL_HOST', 'localhost')
SENTRY_OPTIONS["mail.list-namespace"] = env("SENTRY_MAIL_HOST", "localhost")
SENTRY_OPTIONS["mail.from"] = f"sentry@{SENTRY_OPTIONS['mail.list-namespace']}"

############
Expand Down Expand Up @@ -283,7 +293,7 @@ def get_db_secret_from_secrets_manager(secret_name, region_name="eu-west-1"):
# MaxMind Integration #
#######################

GEOIP_PATH_MMDB = '/geoip/GeoLite2-City.mmdb'
GEOIP_PATH_MMDB = "/geoip/GeoLite2-City.mmdb"

#########################
# Bitbucket Integration #
Expand Down

0 comments on commit ef92033

Please sign in to comment.