Commit 43ff705
feat(secrets): auto-extract API key from JSON-structured Secrets Manager secrets (#1146)
## Summary
- When `DD_API_KEY_SECRET_ARN` is set and the fetched secret is a JSON
object, automatically extract the `dd_api_key` field as the API key
- Falls back to the raw secret string if the value is not valid JSON or
the `dd_api_key` field is absent — preserving existing behavior for
plain-string secrets
- No new environment variable introduced; the JSON key name is hardcoded
as `dd_api_key`
## Test Plan
- [x] Unit tests cover JSON extraction (`dd_api_key` present), fallback
to raw (key absent), and plain string secrets
- [x] Verify with a real Secrets Manager secret in JSON format:
`{"dd_api_key": "<your-key>"}`
- [x] Verify plain-string secrets continue to work unchanged
- [x] Integration test using [test
function](https://us-east-1.console.aws.amazon.com/lambda/home?region=us-east-1#/functions/integ-tianning-base-node-lambda?subtab=envVars&tab=testing),
secret in
[Json](https://us-east-1.console.aws.amazon.com/secretsmanager/secret?name=secret-in-json®ion=us-east-1)
and secret in [plain
text](https://us-east-1.console.aws.amazon.com/secretsmanager/secret?name=securet-with-plain-text®ion=us-east-1).
The positive and negative tests all performed as expected.
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 4dab37a commit 43ff705
1 file changed
+46
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
205 | 211 | | |
| 212 | + | |
206 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
207 | 219 | | |
208 | 220 | | |
209 | 221 | | |
| |||
419 | 431 | | |
420 | 432 | | |
421 | 433 | | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
422 | 468 | | |
423 | 469 | | |
424 | 470 | | |
| |||
0 commit comments