@@ -108,19 +108,20 @@ def submit_errors_metric(lambda_context):
108
108
109
109
110
110
# Set API Key and Host in the module, so they only set once per container
111
- DD_API_KEY_SECRET_ARN = os .environ .get ("DD_API_KEY_SECRET_ARN" , "" )
112
- DD_KMS_API_KEY = os .environ .get ("DD_KMS_API_KEY" , "" )
113
- DD_API_KEY = os .environ .get ("DD_API_KEY" , os .environ .get ("DATADOG_API_KEY" , "" ))
114
- if DD_API_KEY_SECRET_ARN :
115
- api ._api_key = boto3 .client ("secretsmanager" ).get_secret_value (
116
- SecretId = DD_API_KEY_SECRET_ARN
117
- )["SecretString" ]
118
- elif DD_KMS_API_KEY :
119
- api ._api_key = boto3 .client ("kms" ).decrypt (
120
- CiphertextBlob = base64 .b64decode (DD_KMS_API_KEY )
121
- )["Plaintext" ]
122
- else :
123
- api ._api_key = DD_API_KEY
111
+ if not api ._api_key :
112
+ DD_API_KEY_SECRET_ARN = os .environ .get ("DD_API_KEY_SECRET_ARN" , "" )
113
+ DD_KMS_API_KEY = os .environ .get ("DD_KMS_API_KEY" , "" )
114
+ DD_API_KEY = os .environ .get ("DD_API_KEY" , os .environ .get ("DATADOG_API_KEY" , "" ))
115
+ if DD_API_KEY_SECRET_ARN :
116
+ api ._api_key = boto3 .client ("secretsmanager" ).get_secret_value (
117
+ SecretId = DD_API_KEY_SECRET_ARN
118
+ )["SecretString" ]
119
+ elif DD_KMS_API_KEY :
120
+ api ._api_key = boto3 .client ("kms" ).decrypt (
121
+ CiphertextBlob = base64 .b64decode (DD_KMS_API_KEY )
122
+ )["Plaintext" ]
123
+ else :
124
+ api ._api_key = DD_API_KEY
124
125
logger .debug ("Setting DATADOG_API_KEY of length %d" , len (api ._api_key ))
125
126
126
127
# Set DATADOG_HOST, to send data to a non-default Datadog datacenter
0 commit comments