-
Notifications
You must be signed in to change notification settings - Fork 46
Add support for DD_API_KEY_SECRET_ARN
environment variable
#101
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
Conversation
…nvivorment variables
DD_API_KEY_SECRET_ARN
environment variable
@skatsuta Thanks for your great contribution! But unfortunately our readme must mislead you and I'm very sorry 🙇 . When using the Lambda Extension (serverless agent), this go library actually does NOT even need the Datadog API Key at all. Only the Extension needs the Datadog API Key and the Extension already support Therefore, the right fix is actually simpler, we just need to update this line Lines 266 to 267 in 23c42de
isExtensionRunning
We actually just fixed something similar for the Node.js library here DataDog/datadog-lambda-js#273. Again, very sorry for the confusion we have caused 🙇♂️ If you are interested in updating your PR, let me know. Otherwise, we should be able to find a Datadog engineer to fix this soon. |
@tianchu Oh, I see! I actually wondered about that, "Does this library really need an API key when using the Lambda Extension? Isn't it only Serverless Agent that needs to use an API key?" Sure, I'm willing to make the fix you suggest if necessary, but as for the README, I'm not sure how to fix it, so would it be okay if I just fix the line of code you pointed out (and test it in my microservice)? If the above fix is OK, I will either update this PR (actually, I will delete all current commits and force push the above fix), or close this PR and create a new one with only the above fix. |
@skatsuta Thanks, if you are willing to help, please go ahead make the code changes 🙇♂️ I 'm happy to take care of the readme update separately. |
@tianchu Thanks for your support! I'm closing this PR and will make a new one. |
Created #102 |
What does this PR do?
Adds support for
DD_API_KEY_SECRET_ARN
environment variable.Closes #98.
Motivation
When using the Datadog Lambda Extension for Lambda APM, it is necessary to set the API key to an environment variable, but it is not secure to set the API key in plain text to
DD_API_KEY
.I use
DD_KMS_API_KEY
for this reason, but I felt it was very troublesome to have to encrypt the key using KMS.I looked at Serverless Agent and found that it also supports
DD_API_KEY_SECRET_ARN
, which I think would be very useful.I also saw #98 and knew that there were others with similar needs.
So I wanted to add support for
DD_API_KEY_SECRET_ARN
to this library.I believe this feature would be very beneficial to Datadog users who use the Lambda Extension.
Testing Guidelines
I first tagged this working branch in my forked repository, added a
replace
directive togo.mod
for our microservice that uses this library so that it uses my forked repository instead, and built the Go binary.I then set
DD_API_KEY_SECRET_ARN
instead ofDD_KMS_API_KEY
to environment variables for the microservice's Lambda function, and deployed the binary to Lambda.Finally, I ran this Lambda function and confirmed that metrics and traces were sent to Datadog as expected.
I also confirmed that the debug logs I added were output on CloudWatch Logs.
I strongly felt that not having to set the API key (even if it is encrypted) directly to an environment variable is a very good user experience.
Additional Notes
I also added an explanation for
DD_KMS_API_KEY
andDD_API_KEY_SECRET_ARN
to README, but I'm not sure if this explanation is clear enough for users, so if you have any idea to improve it, I would appreciate it.Types of changes
Checklist