Repository navigation
feat(trigger): reach AWS from trigger.dev runs through workload identity - #9578
Conversation
Trigger.dev runs reached S3, AppConfig, CloudWatch and hosted Bedrock with the app IAM user's static keys. With TRIGGER_AWS_ROLE_ARN set, Sim's own AWS clients now use temporary credentials for that role, exchanged for the run's Trigger.dev workload-identity token (SDK 4.8.3). One session serves the worker process, refreshed at each attempt's start so the post-run metrics flush keeps valid credentials. Static keys and the default chain are unchanged for ECS and self-hosted deployments.
4.8.3 is the first release with workload identity. The exclusion is temporary and comes out once it clears the 7-day threshold on 2026-11-06. Hosted-key metrics now key off Sim Cloud itself instead of the presence of static AWS keys, so removing those keys never silences them.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
[High impact] The PR appears safe to merge; no actionable issues remain in the reviewed changes. SummaryAdds workload identity for Sim-owned AWS clients in Trigger.dev runs.
Both earlier review threads are addressed: the default lookup preserves session tokens, and SES now receives workload credentials. No new actionable issues were found.
|
The init hook loads app modules by relative path, which the source-convention ratchet caps. Warming Redis and refreshing workload-identity credentials now sit behind prepareTriggerAttempt, so init still imports one module.
getAwsCredentials returned explicit static keys when present, which dropped AWS_SESSION_TOKEN for clients that used to reach it through the default chain (Bedrock, CloudWatch). It now returns the workload-identity provider or undefined, so every non-Trigger path resolves exactly as before. The SES email client reads it too, so worker email keeps working once static keys leave Trigger.dev. The release-age comment records why the exclusions are bare names.
…ads them The S3 client resolves credentials through the SDK default chain, which reads process.env, so the presigner test stubs the keys there instead of the env module mock.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 16 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
Outside an executing attempt no workload-identity token can be minted, so a post-run metrics flush near the refresh window failed even though the cached credentials were still valid. A failed exchange now keeps serving the cached credentials until a minute before they expire.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Why
Trigger.dev runs reach Sim's own AWS resources (S3 file storage, AppConfig, the hosted-key CloudWatch metrics, hosted Bedrock) with long-lived IAM access keys stored as Trigger.dev environment variables. Trigger.dev 4.8.3 issues short-lived workload-identity (OIDC) tokens to executing runs, which AWS STS exchanges for temporary credentials. With that, no AWS key needs to live in Trigger.dev at all.
What
lib/core/config/aws.ts:getAwsCredentials()is now the single source of credentials for Sim's own AWS clients. It picks one of three sources, in this order:TRIGGER_AWS_ROLE_ARNis set (deployed Trigger.dev runs): temporary credentials for that role, fromawsCredentialProviderin@trigger.dev/sdk/oidc/aws. This takes precedence over static keys, so a failed exchange shows up as an error instead of silently falling back to a stored key, as Trigger.dev's docs require.AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY, unchanged for self-hosted deployments.undefined, so the default chain applies (the ECS task role).Wiring
Credential lifetime. Sim's AWS clients live for the whole process, while a token can only be minted while an attempt is executing. So:
sim-trigger-worker, rather than run-named, so later runs' calls aren't attributed to the run that minted it.trigger.config.tsinitat the start of each attempt, whenever less than 30 minutes remain. Work a run leaves behind, such as the 5-second metrics flush, still has valid credentials after the attempt ends.Hosted-key metrics now turn on based on
isHostedrather than on whetherAWS_ACCESS_KEY_IDis present. Hosted keys only exist on Sim Cloud, and removing static keys must not turn the metrics off.Trigger.dev 4.8.3
minimumReleaseAgeExcludesuntil it clears the 7-day window on 2026-11-06; the comment says to drop it then.Rollout
Nothing changes until
TRIGGER_AWS_ROLE_ARNis set in a Trigger.dev environment. Without it, runs keep today's static keys.For each environment:
ECS is unaffected: it never sets the variable.
Verification
Type-check passes across all 29 workspaces. The real proof is end to end, on staging after merge:
AssumeRoleWithWebIdentityevents from staging runs appear in CloudTrail.