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

feat(api): load all secrets in lambdas #641

Merged
merged 1 commit into from
Jul 23, 2024
Merged
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
13 changes: 5 additions & 8 deletions api/aws_lambdas/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ def load_secrets():
# Decrypts secret using the associated KMS key.
# Load secrets and store them in env variables
secrets = json.loads(get_secret_value_response["SecretString"])
os.environ["SECRET_KEY"] = secrets["SECRET_KEY"]
os.environ["S3_DATA_AWS_SECRET_KEY_ID"] = secrets["S3_DATA_AWS_SECRET_KEY_ID"]
os.environ["S3_DATA_AWS_SECRET_ACCESS_KEY"] = secrets[
"S3_DATA_AWS_SECRET_ACCESS_KEY"
]
for key in secrets:
os.environ[key] = secrets[key]


if "SCORER_SERVER_SSM_ARN" in os.environ:
Expand All @@ -79,6 +76,9 @@ def load_secrets():
from django_ratelimit.exceptions import Ratelimited # noqa: E402
from ninja_extra.exceptions import APIException
from ninja_jwt.exceptions import InvalidToken # noqa: E402
from structlog.contextvars import bind_contextvars # noqa: E402

lucianHymer marked this conversation as resolved.
Show resolved Hide resolved
from aws_lambdas.exceptions import InvalidRequest # noqa: E402
from registry.api.utils import (
ApiKey,
check_rate_limit,
Expand All @@ -89,9 +89,6 @@ def load_secrets():
NotFoundApiException,
Unauthorized,
)
from structlog.contextvars import bind_contextvars # noqa: E402

from aws_lambdas.exceptions import InvalidRequest # noqa: E402

RESPONSE_HEADERS = {
"Content-Type": "application/json",
Expand Down
Loading