Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: Please remember to review the Datadog Contribution Guidelines
if you have not yet done so.
What does this PR do?
Allows a user to pass in the Datadog API key to the install script as an argument rather than as an environment variable.
Motivation
Trying to get the agent to install using AWS SSM was proving troublesome. Despite exporting the variable correctly, I kept getting the "API key not available in DD_API_KEY environment variable" message. Plus, it seemed a little odd to go through two steps (create variable, run script) when you could do it in a single step (script plus argument). As it appears it's the only external input required, it seems sensible you should be able to put the key in that way! Environment variables take precedence and a blank still throws an error to alert people.
Testing Guidelines
It's a 3 line edit to the Agent Installer. The old use case, failure case and this all work.
Additional Notes
I didn't upgrade the error message (it still implicitly expects an Environment Variable) as I assume you want that to be the primary method of injecting the key.