[SVLS-9488] fix(secrets): recognize apiKey field in JSON Secrets Manager secrets#1305
Draft
litianningdatadog wants to merge 2 commits into
Draft
[SVLS-9488] fix(secrets): recognize apiKey field in JSON Secrets Manager secrets#1305litianningdatadog wants to merge 2 commits into
litianningdatadog wants to merge 2 commits into
Conversation
…ger secrets AWS's Managed Rotation for Datadog API Key secret type uses the field name `apiKey`, not our own `dd_api_key` convention. Check `dd_api_key` first, then fall back to `apiKey`, before falling back to the raw secret string. Fixes #1304
This comment has been minimized.
This comment has been minimized.
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Secrets Manager JSON-secret parsing so DD_API_KEY_SECRET_ARN can consume AWS’s “Managed Rotation for Datadog API Key” secret type, which stores the key under apiKey instead of the extension’s existing dd_api_key convention.
Changes:
- Extend JSON secret extraction to check
dd_api_keyfirst, then fall back toapiKey, then fall back to treating the secret as a raw string. - Add unit tests covering
apiKeyextraction and precedence when bothdd_api_keyandapiKeyare present.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://datadoghq.atlassian.net/browse/SVLS-9488
Overview
AWS's Managed Rotation for Datadog API Key Secrets Manager secret type stores the API key under the field
apiKey(alongsideapiKeyId), not our owndd_api_keyconvention added in #1146. As a result,DD_API_KEY_SECRET_ARNcouldn't consume that AWS-managed secret type.extract_secret_stringnow checksdd_api_keyfirst (unchanged), then falls back toapiKey, before falling back to treating the secret as a raw string.Fixes #1304
Testing
test_json_secret_extraction_api_key— secret shaped like AWS's managed-rotation type ({"apiKey":"...","apiKeyId":"..."}) extracts the API key.test_json_secret_dd_api_key_takes_precedence_over_api_key— when both fields are present,dd_api_keywins.test_json_secret_extraction,test_json_secret_missing_key_falls_back_to_raw,test_plain_secret_unaffected,test_malformed_json_secret_falls_back_to_raw) continue to pass unchanged.cargo test --lib secrets::decrypt— 11/11 passing.cargo clippy— clean on the changed file.