Llim.run

Authenticate AWS workloads with workload identity federation

AWS outbound identity federation lets an IAM role request a signed JWT from AWS STS. A workload running as that role, such as an EC2 instance, an ECS task, or a Lambda function, can exchange the JWT for a short-lived Limrun access token. No Limrun API key is stored in AWS.

Before you start

You need:

Enable outbound identity federation

Each AWS account has its own issuer, so you enable the feature once per account and copy the issuer from AWS:

aws iam enable-outbound-web-identity-federation
aws iam get-outbound-web-identity-federation-info

The second command prints IssuerIdentifier, a URL like https://EXAMPLE.tokens.sts.global.api.aws. Copy it exactly. Disabling and enabling the feature again gives the account new signing keys.

Then allow the workload's IAM role to request tokens by adding sts:GetWebIdentityToken to its policy. AWS also offers the condition key sts:IdentityTokenAudience if you want to limit the role to the audience limrun.

Create the provider

Your account's issuer signs only for your account, but any role in the account that may call sts:GetWebIdentityToken can get a token. The provider condition limits trust to the role that should reach Limrun.

  1. Open console.limrun.com, go to Settings, then Workload identity federation, and click the + button next to Identity providers.

  2. In Issuer, choose Amazon Web Services (AWS).

  3. Enter a provider name and paste the IssuerIdentifier as the Issuer URL. The preset adds the signing keys at /.well-known/jwks.json under the issuer.

  4. Keep Token audience as limrun.

  5. In Provider condition (CEL), replace ACCOUNT_ID and ROLE_NAME with your account ID and the workload's role:

    assertion.sub == 'arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME'

    AWS puts the requesting role's ARN in sub. Run aws sts get-caller-identity --query Account --output text to print your account ID.

  6. Click Create provider.

Create a binding

  1. In the provider's card, click the + button next to Bindings.

  2. Enter a name and a Claim condition (CEL). The provider condition already selects the role, so true admits it. AWS puts its other claims, such as aws_account and source_region, inside an object named https://sts.amazonaws.com/, so read them by index:

    assertion['https://sts.amazonaws.com/'].source_region == 'us-east-1'
  3. Enter the permissions the workload needs, one per line, such as xcode:*:all.

  4. Click Create binding, expand Setup, and copy the binding ID.

Use the token in the workload

Request tokens from a regional STS endpoint; the global endpoint doesn't serve them. AWS tokens last 300 seconds unless you set --duration-seconds, up to 3,600, and a Limrun access token never outlives its source token. This script keeps a fresh token in a file, which the CLI reads again whenever it renews:

export AWS_REGION=us-east-1
export LIMRUN_WORKLOAD_IDENTITY_BINDING_ID=binding_REPLACE_WITH_BINDING_ID
export LIMRUN_WORKLOAD_IDENTITY_TOKEN_FILE=/tmp/limrun.jwt

refresh() {
  aws sts get-web-identity-token \
    --region "$AWS_REGION" \
    --endpoint-url "https://sts.$AWS_REGION.amazonaws.com" \
    --audience limrun \
    --signing-algorithm RS256 \
    --duration-seconds 900 \
    --query WebIdentityToken --output text > "$LIMRUN_WORKLOAD_IDENTITY_TOKEN_FILE.tmp"
  mv "$LIMRUN_WORKLOAD_IDENTITY_TOKEN_FILE.tmp" "$LIMRUN_WORKLOAD_IDENTITY_TOKEN_FILE"
}
refresh
(while sleep 600; do refresh; done) &

lim whoami

--audience limrun must match the provider's audience. --signing-algorithm accepts RS256 or ES384, and Limrun verifies both. Writing to a temporary file and renaming it means the CLI never reads a half-written token. lim whoami prints your organization and the binding's permissions.

In code, call the STS GetWebIdentityToken API from a token function instead of running a background loop. With the TypeScript SDK, pass a function that returns the WebIdentityToken field as workloadToken. The Python SDK's workload_token and the Go SDK's TokenSource work the same way.

Things to know

See AWS outbound identity federation and its token claims for the AWS side.