Repository navigation
Conversation
Add the experimental temporal-aws-secrets-manager module, an envconfig extension that loads the client API key and mTLS material from AWS Secrets Manager secret IDs, configured in TOML or with TEMPORAL_EXT_AWS_SECRETS_MANAGER_* environment variables. It ports the Go, Python and TypeScript implementations, with the same config, validation, metric names and log messages. Secrets are fetched through the AWS Parameters and Secrets Lambda Extension when it's detected, and otherwise with the AWS SDK for Java 2.x. The AWS SDK is a compile-only dependency that users add when they need it, and only SdkFetcher references it, so the module loads without it. Fetched secrets are cached, refreshed every refresh interval (SECRETS_MANAGER_TTL, default 5 minutes), and fall back to the previous value for up to 24 hours if a refresh fails. The plugin fetches the secrets when service stubs are created. The API key supplier returns the cached key and refreshes it in the background, so requests never wait on a fetch. TLS secrets are combined with the profile's other TLS settings into a new SSL context, since an SslContext can't be extended. Client keys must be PKCS#8, as for envconfig, and a client cert and key that don't match are treated as a failed fetch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Lambda worker now always loads its client config with the AWS Secrets Manager extension, so credentials can be configured as secret IDs with TEMPORAL_EXT_AWS_SECRETS_MANAGER_* environment variables or in temporal.toml. The extension only adds a plugin when secret IDs are configured. Functions without the AWS Parameters and Secrets Lambda Extension need to add software.amazon.awssdk:secretsmanager, since the Lambda Java runtimes don't include the AWS SDK. OtelLambdaWorkerConfigurationHelper now adds its OpenTelemetry plugin before existing service stubs plugins rather than after them, so its metrics scope is already set when the Secrets Manager plugin fetches TLS secrets while the stubs are configured. Before, those fetches reported to a no-op scope. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eamsden
requested changes
Nov 20, 2026
Comment on lines
+294
to
+315
| <T> T getNow(CacheEntry<T> entry, long minRefreshIntervalNanos, Telemetry tel) { | ||
| long start; | ||
| boolean canUseStale; | ||
| T value; | ||
| CompletableFuture<T> fetch = null; | ||
| synchronized (entry) { | ||
| start = now.getAsLong(); | ||
| value = entry.value; | ||
| canUseStale = entry.versionIds != null && start - entry.fetchedAt < maxStalenessNanos; | ||
| if (entry.inFlight == null | ||
| && start - entry.fetchedAt >= Math.max(refreshIntervalNanos, minRefreshIntervalNanos) | ||
| && (entry.failedAt == null | ||
| || start - entry.failedAt >= FAILED_REFRESH_RETRY_INTERVAL_NANOS)) { | ||
| fetch = new CompletableFuture<>(); | ||
| entry.inFlight = fetch; | ||
| } | ||
| } | ||
| if (fetch != null) { | ||
| startFetch(entry, fetch, start, canUseStale, tel); | ||
| } | ||
| return value; | ||
| } |
Contributor
There was a problem hiding this comment.
This does not actually check the maximum staleness, meaning that SecretsManagerPlugin will return API keys without respecting maxStaleness at all.
@Test
public void apiKeyLookupMustRespectMaxStaleness() {
fetcher.set("key", "v1", "ver1");
SecretCache cache = newApiKeyCache(REFRESH);
cache.executor = Runnable::run; // Complete refreshes synchronously; no sleeps or races.
assertEquals("v1", cache.get(cache.apiKey, tel));
fetcher.fail("key", new Exception("Secrets Manager unavailable"));
clock.addAndGet(REFRESH);
assertEquals("v1", cache.getNow(cache.apiKey, RETRY, tel));
assertEquals(2, fetcher.calls("key")); // Initial fetch plus failed refresh.
clock.addAndGet(MAX_STALENESS); // The cached key is now older than the maximum age.
assertThrows(SecretFetchException.class, () -> cache.get(cache.apiKey, tel));
// The per-RPC API-key path must also refuse the expired credential.
assertThrows(SecretFetchException.class, () -> cache.getNow(cache.apiKey, RETRY, tel));
}
Contributor
Author
There was a problem hiding this comment.
Same subtlety as the TypeScript implementation. Took the same approach of returning the stale value until the first refresh fails.
- Send an empty API key once no value has been fetched within the max staleness, instead of sending the stale key indefinitely, so calls fail until a refresh succeeds. The removal is logged with the fetch error that caused it, and unexpected errors getting the key are logged and treated the same way. - The per-request key lookup doesn't wait for a fetch, so it keeps returning an expired key until a refresh attempted after it expired fails. Otherwise requests would go without a key while a healthy refresh is in progress, e.g. the first request after being idle for longer than the max staleness. - Never leave a fetch in flight forever, including when fetching or starting it throws an Error (e.g. a LinkageError from a mismatched AWS SDK version), which is rethrown once the cache is consistent. Don't let a failing logger affect recording metrics. - Raise the Lambda extension probe timeout, since it only bounds pathological cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jackson's parse error messages can quote the input, e.g. as the source in the error location, or an unrecognized token. For a malformed Lambda extension response, that could include the secret, which would then be logged and thrown with the fetch error. The error now just says the response is invalid JSON, without the parse error as the message or cause. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only an unset max staleness uses the 24 hour default. Previously 0 also did, as in Go, where a zero duration means unset. Here unset is already distinct, so 0 now means no tolerance for stale values beyond the refresh interval, rather than the most permissive setting, and a negative value is rejected like a negative refresh interval. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eamsden
approved these changes
Nov 24, 2026
eamsden
approved these changes
Nov 24, 2026
This branch has not been deployed
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.
What was changed
The temporal-aws-secrets-manager module defines a new envconfig extension to support Temporal client credentials stored in AWS Secrets Manager. The user specifies a secret ARN or friendly name via envconfig (TOML or environment variables), and the client will automatically fetch the secret material from Secrets Manager. Periodic refreshes are only supported for API keys for now, with TLS cert rotation support deferred to later since there's no easy way to do it right now.
The AWS Parameters and Secrets Lambda Extension is used if detected in the environment. Otherwise, secrets are retrieved directly from Secrets Manager.
See the README or module documentation for usage details.
The temporal-aws-lambda module now uses the secretsmanager envconfig extension to support Temporal credentials in AWS Secrets Manager within Lambda workers.
Also see the Go reference implementation:
Why?
The temporal-aws-secrets-manager extension is intended to be used with the Lambda worker contrib package (and in the future other serverless providers), to make it more convenient to store worker secrets in a secrets manager when using serverless. This makes it more convenient to store worker secrets in a secrets manager when using serverless.
Checklist
How was this tested:
Added new unit tests. Also did Claude-assisted E2E verification with a serverless Lambda worker setup configured to read credentials from Secrets Manager (under multiple configurations, including with/without the Lambda extension fetcher, with/without TLS client cert bundling, and using TOML/env vars).
Any docs updates needed?
The associated in-repo docs are updated. This specific module is primarily an implementation detail for the Lambda worker integration with Secrets Manager. We'll probably want to update our public docs for Lambda workers, but that can be done later. We may also want to update the associated sample code in samples-typescript to at least mention this integration as an option.