awsCredentialProvider to exchange a Trigger.dev OIDC token for temporary AWS credentials through STS. Pass it to your AWS SDK client to obtain and refresh credentials automatically.
Follow the OIDC prerequisites, then go to the OIDC page for your environment and copy the issuer URL and subject.
Configure AWS
Create an OIDC identity provider
In AWS IAM, add an OpenID Connect identity provider with:- Provider URL: your issuer URL,
https://oidc.trigger.dev/YOUR_ORG_SLUG. - Audience:
sts.amazonaws.com, the audience used by the SDK’s AWS helper.
Create an IAM role
Create a role with this trust policy. Replace the AWS account ID and organization slug, and replaceYOUR_ENVIRONMENT_SUBJECT with the complete subject copied from the dashboard.
s3:GetObject on arn:aws:s3:::YOUR_BUCKET/trigger/*. The trust policy controls who can assume the role; it does not grant S3 permissions. No session tags are required.
Use the role in your task
Install the STS peer dependency and the AWS clients your task uses:Provider options
For local development, use your own AWS credential chain, such as an AWS SSO profile. If a task runs both locally and deployed, select local credentials explicitly when
ctx.environment.type === "DEVELOPMENT".
Session tags and task-level access
By default, a role’s trust policy only checks the environment subject, so every task in that environment can assume the role. Session tags let you restrict a role to specific tasks, or scope resource permissions by task. They are off by default; existing roles keep working unchanged. Trigger.dev adds these tags to the signed token. Values come from the verified run, never from payloads or caller input:
These are AWS session tags, not Trigger.dev run tags. They are not transitive across role chaining.
Restrict a role to one task
- Update the trust policy. Add
sts:TagSessiontoActionand aTriggerTaskIdcondition. AWS rejects tagged tokens ifsts:TagSessionis missing.
- Enable tags in the task with
@trigger.dev/sdk4.8.4 or later, then redeploy:
sessionTags in TypeScript and silently ignore it in JavaScript, which sends untagged tokens that this policy rejects.
To use tags only in permissions (below) without restricting tasks, add sts:TagSession to Action and omit the aws:RequestTag condition.
Use tags in resource permissions
Tags are available in the role’s permissions asaws:PrincipalTag/.... For example, one role can give each task its own S3 prefix:
Without the helper
Request tags withauth.getOIDCToken({ audience: "sts.amazonaws.com", awsSessionTags: true }). Other audiences are rejected. Task IDs are sent unchanged, so a task ID that exceeds AWS session tag limits makes the STS call fail.
Trust all Preview branches
For a single Preview environment, use its exact subject. To allow any task across all current and future Preview branches in one project, start with the basic trust policy in Create an IAM role and replace itsCondition with:
sts:TagSession in Action and add the task condition to StringEquals:
PREVIEW environment type, and audience fixed. This deliberately grants access to anyone allowed to deploy a Preview branch in that project. Never wildcard the organization or project, or use this policy for a role intended only for Production or Staging.
