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 secret_key for getting secret value #376

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions aws/logs_monitoring/settings.py
Expand Up @@ -9,7 +9,7 @@
import boto3
import logging
import re

import json

logger = logging.getLogger()
logger.setLevel(logging.getLevelName(os.environ.get("DD_LOG_LEVEL", "INFO").upper()))
Expand Down Expand Up @@ -181,9 +181,14 @@ def __init__(self, name, pattern, placeholder):
# DD API Key
if "DD_API_KEY_SECRET_ARN" in os.environ:
SECRET_ARN = os.environ["DD_API_KEY_SECRET_ARN"]
DD_API_KEY = boto3.client("secretsmanager").get_secret_value(SecretId=SECRET_ARN)[
secretstring = boto3.client("secretsmanager").get_secret_value(SecretId=SECRET_ARN)[
"SecretString"
]
if "DD_API_KEY_SECRET_KEY" in os.environ:
SECRET_KEY = os.environ["DD_API_KEY_SECRET_KEY"]
DD_API_KEY = json.loads(secretstring)[SECRET_KEY]
else:
DD_API_KEY = secretstring
elif "DD_API_KEY_SSM_NAME" in os.environ:
SECRET_NAME = os.environ["DD_API_KEY_SSM_NAME"]
DD_API_KEY = boto3.client("ssm").get_parameter(
Expand Down