Skip to content

[extension/basicauth] Add AWS Secrets Manager support for client credentials#48380

Closed
lazureykis wants to merge 4 commits into
open-telemetry:mainfrom
lazureykis:feat/basicauth-aws-secrets-manager
Closed

[extension/basicauth] Add AWS Secrets Manager support for client credentials#48380
lazureykis wants to merge 4 commits into
open-telemetry:mainfrom
lazureykis:feat/basicauth-aws-secrets-manager

Conversation

@lazureykis
Copy link
Copy Markdown
Contributor

Summary

  • Add client_auth.aws_secrets_manager option that polls a JSON secret from AWS Secrets Manager and rotates credentials in place without restarting the collector
  • Credentials are stored as an atomic pair to guarantee consistency under concurrent reads
  • On poll failure, the extension logs a warning and retains the last known good credentials
  • Mutually exclusive with existing username/password/*_file options

Resolves #48277

Configuration example

extensions:
  basicauth/client:
    client_auth:
      aws_secrets_manager:
        secret_arn: "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-creds"
        region: "us-east-1"
        refresh_interval: 30m
        username_key: "username"
        password_key: "password"

Test plan

  • Unit tests covering initial fetch, atomic pair consistency, rotation detection, error resilience, custom keys, shutdown, and config validation
  • All tests pass with -race
  • Linter passes

…ential rotation

Adds native support for sourcing client auth credentials from AWS Secrets
Manager. The extension polls the secret at a configurable interval and swaps
credentials in place when a rotation is detected — no collector restart required.

The secret must be a JSON object. Key names default to "username" and "password"
(matching AWS's own RDS/Redshift/DocumentDB rotation templates) and are
configurable via username_key and password_key. AWS credentials use the standard
SDK default chain (env vars, instance profile, ECS/EKS task role, etc.).

On poll failure, the extension logs a warning and retains the last known good
credentials. The collector is not interrupted.

Closes open-telemetry#48277

Assisted-by: Claude Sonnet 4.6
- Replace two separate atomic.Pointer[string] for username/password with a
  single atomic.Pointer[secretCredentials] so HTTP clients always read a
  consistent credential pair (fixes torn-read window during rotation)
- Capture shutdownCh in local variable before spawning cancel goroutine to
  avoid race with shutdown() zeroing the field (detected by go test -race)
- Add idempotency guard to startWithClient (returns error if already started)
- Pass cancellable context into fetch() so in-flight AWS calls respect shutdown
- Remove redundant updateGRPCMetadata() call in Start(); onChange handles it
- Fix mock.callErr data race in tests by using atomic.Pointer[error]
- Replace time.Sleep with assert.Eventually in NoOnChange and PollError tests
- Add TestClientAuthSettingsValidate covering all Validate() error branches
- Add TestBasicAuth_ClientAWSSecretsManager integration test through extension

Assisted-by: Claude Sonnet 4.6
@lazureykis
Copy link
Copy Markdown
Contributor Author

Closing this in favor of a different approach suggested by @thomasbaldwin in #48277.

Instead of adding the AWS SDK dependency directly to basicauthextension, I'm first extracting the shared basic auth logic into extension/internal/basicauth (#48414) so that a standalone AWS Secrets Manager auth extension can reuse it without duplicating code. The AWS-specific extension will follow as a separate PR on top of that.

@lazureykis lazureykis closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[extension/basicauth] Add support for rotating credentials sourced from cloud secret managers

2 participants