Skip to content

[SVLS-9488] fix(secrets): recognize apiKey field in JSON Secrets Manager secrets#1305

Draft
litianningdatadog wants to merge 2 commits into
mainfrom
tianning.li/SVLS-9488
Draft

[SVLS-9488] fix(secrets): recognize apiKey field in JSON Secrets Manager secrets#1305
litianningdatadog wants to merge 2 commits into
mainfrom
tianning.li/SVLS-9488

Conversation

@litianningdatadog

@litianningdatadog litianningdatadog commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

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 (alongside apiKeyId), not our own dd_api_key convention added in #1146. As a result, DD_API_KEY_SECRET_ARN couldn't consume that AWS-managed secret type.

extract_secret_string now checks dd_api_key first (unchanged), then falls back to apiKey, before falling back to treating the secret as a raw string.

Fixes #1304

Testing

  • Added test_json_secret_extraction_api_key — secret shaped like AWS's managed-rotation type ({"apiKey":"...","apiKeyId":"..."}) extracts the API key.
  • Added test_json_secret_dd_api_key_takes_precedence_over_api_key — when both fields are present, dd_api_key wins.
  • Existing tests (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.

…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
@datadog-prod-us1-5

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_key first, then fall back to apiKey, then fall back to treating the secret as a raw string.
  • Add unit tests covering apiKey extraction and precedence when both dd_api_key and apiKey are present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AWS - SecretsManager API Key extraction doesn't match Managed Secrets Rotation field name (apiKey, not dd_api_key)

2 participants