Skip to content
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
25 changes: 24 additions & 1 deletion aws/logs_monitoring/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,32 @@ def get_env_var(envvar, default, boolean=False):
############# PARAMETERS ############
#####################################

## @param DD_API_KEY - String - required - default: none
## @param DD_API_KEY - String - conditional - default: none
## The Datadog API key associated with your Datadog Account
## It can be found here:
##
## * Datadog US Site: https://app.datadoghq.com/account/settings#api
## * Datadog EU Site: https://app.datadoghq.eu/account/settings#api
##
## Must be set if one of the following is not set: DD_API_KEY_SECRET_ARN, DD_API_KEY_SSM_NAME, DD_KMS_API_KEY
#
DD_API_KEY = "<YOUR_DATADOG_API_KEY>"

## @param DD_API_KEY_SECRET_ARN - String - optional - default: none
## ARN of Datadog API key stored in AWS Secrets Manager
##
## Supercedes: DD_API_KEY_SSM_NAME, DD_KMS_API_KEY, DD_API_KEY

## @param DD_API_KEY_SSM_NAME - String - optional - default: none
## Name of parameter containing Datadog API key in AWS SSM Parameter Store
##
## Supercedes: DD_KMS_API_KEY, DD_API_KEY

## @param DD_KMS_API_KEY - String - optional - default: none
## AWS KMS encrypted Datadog API key
##
## Supercedes: DD_API_KEY

## @param DD_FORWARD_LOG - boolean - optional - default: true
## Set this variable to `False` to disable log forwarding.
## E.g., when you only want to forward metrics from logs.
Expand Down Expand Up @@ -220,6 +237,12 @@ def compileRegex(rule, pattern):
DD_API_KEY = boto3.client("secretsmanager").get_secret_value(
SecretId=SECRET_ARN
)["SecretString"]
elif "DD_API_KEY_SSM_NAME" in os.environ:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rename this it DD_SSM_API_KEY, just to keep it consistent with DD_KMS_API_KEY

Copy link
Contributor

@DarcyRaynerDD DarcyRaynerDD Jan 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marshall0705, I forgot to submit the review, doh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had considered naming it that. It was a choice between the convention used for the secrets manager var, and the convention used for the KMS var.
I chose this name due to DD_KMS_API_KEY and DD_API_KEY both actually containing the key (albeit one of them encrypted), whereas DD_API_KEY_SECRET_ARN is a reference to a remote location, as is DD_API_KEY_SSM_NAME.
If you would still like the name changing, I'm fine to do so.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I think we can keep your naming convention then. I'll merge this and roll it out into the next release.

SECRET_NAME = os.environ["DD_API_KEY_SSM_NAME"]
DD_API_KEY = boto3.client("ssm").get_parameter(
Name=SECRET_NAME,
WithDecryption=True
)["Parameter"]["Value"]
elif "DD_KMS_API_KEY" in os.environ:
ENCRYPTED = os.environ["DD_KMS_API_KEY"]
DD_API_KEY = boto3.client("kms").decrypt(
Expand Down