# Temporary Credentials

<!-- -->

Temporary credentials are short-lived S3 credentials limited to one bucket. They expire on their own, so you can hand them to a job, a host, or a browser without giving out a long-lived access key.

You get temporary credentials from the AWS STS `GetFederationToken` API at `https://sts.storage.dev`. Every AWS SDK and the AWS CLI can call it and can use the credentials it returns, with only the endpoint changed.

## How temporary credentials work[​](#how-temporary-credentials-work "Direct link to How temporary credentials work")

You call `GetFederationToken` with one of your access keys and an IAM policy. The temporary credential it returns can do only what both of these allow:

* The policy you passed to `GetFederationToken`. It names one bucket and a list of actions.
* The access key that issued it. Every request is also checked as if that key made it.

## Get temporary credentials[​](#get-temporary-credentials "Direct link to Get temporary credentials")

* AWS CLI
* Python

```
aws sts get-federation-token \

  --endpoint-url https://sts.storage.dev \

  --region auto \

  --name ci-upload \

  --duration-seconds 3600 \

  --policy '{

    "Version": "2012-10-17",

    "Statement": [

      {

        "Effect": "Allow",

        "Action": ["s3:GetObject", "s3:PutObject", "s3:ListBucket"],

        "Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"]

      }

    ]

  }'
```

```
{

  "Credentials": {

    "AccessKeyId": "tsid_...",

    "SecretAccessKey": "tssec_...",

    "SessionToken": "tsts1....",

    "Expiration": "2026-11-20T13:00:00+00:00"

  },

  "FederatedUser": {

    "FederatedUserId": "<org id>:ci-upload",

    "Arn": "arn:aws:sts::<org id>:federated-user/ci-upload"

  }

}
```

You can also set `AWS_ENDPOINT_URL_STS=https://sts.storage.dev` instead of passing `--endpoint-url`.

```
import json



import boto3



policy = {

    "Version": "2012-10-17",

    "Statement": [

        {

            "Effect": "Allow",

            "Action": ["s3:GetObject", "s3:PutObject", "s3:ListBucket"],

            "Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"],

        }

    ],

}



sts = boto3.client("sts", endpoint_url="https://sts.storage.dev", region_name="auto")

creds = sts.get_federation_token(

    Name="ci-upload",

    DurationSeconds=3600,

    Policy=json.dumps(policy),

)["Credentials"]
```

### Request parameters[​](#request-parameters "Direct link to Request parameters")

| Parameter         | Required | Description                                                                             |
| ----------------- | -------- | --------------------------------------------------------------------------------------- |
| `Name`            | Yes      | 2 to 32 characters from `A-Z a-z 0-9 _ + = , . @ -`. Appears in the federated user ARN. |
| `Policy`          | Yes      | The bucket and actions the credential gets. See [Policy](#policy).                      |
| `DurationSeconds` | No       | Lifetime in seconds, from 900 to 129600 (36 hours). The default is 43200.               |

## Use temporary credentials[​](#use-temporary-credentials "Direct link to Use temporary credentials")

Use the three values like any other credential.

* AWS CLI
* Python

```
export AWS_ACCESS_KEY_ID=tsid_...

export AWS_SECRET_ACCESS_KEY=tssec_...

export AWS_SESSION_TOKEN=tsts1....

export AWS_ENDPOINT_URL_S3=https://t3.storage.dev

export AWS_REGION=auto



aws s3 cp model.bin s3://my-bucket/models/model.bin
```

```
s3 = boto3.client(

    "s3",

    endpoint_url="https://t3.storage.dev",

    region_name="auto",

    aws_access_key_id=creds["AccessKeyId"],

    aws_secret_access_key=creds["SecretAccessKey"],

    aws_session_token=creds["SessionToken"],

)

s3.upload_file("model.bin", "my-bucket", "models/model.bin")
```

warning

Tigris accepts temporary credentials for up to 5 minutes after `Expiration`, to allow for clock differences. Do not rely on `Expiration` as an exact cutoff. A presigned URL made with temporary credentials stops working at the end of that window, even if the URL has a later expiry.

Temporary credentials cannot list or create buckets, call the IAM API, or call `GetFederationToken`. An upload with the `public-read` ACL is refused unless the bucket is already public.

## Policy[​](#policy "Direct link to Policy")

`GetFederationToken` accepts a subset of the IAM policy grammar. Tigris refuses a policy outside this subset; it never drops part of a policy.

* Every statement has `"Effect": "Allow"`.
* `Resource` is `arn:aws:s3:::my-bucket` or `arn:aws:s3:::my-bucket/*`. All statements name the same bucket.
* `Action` lists actions from the table below. A trailing `*` is a wildcard over that table: `s3:Get*` is every read action that starts with `s3:Get`, and `s3:*` is every action in the table.
* `Condition`, `NotAction`, `NotResource`, `Principal`, and `Deny` are not supported. Object prefixes such as `arn:aws:s3:::my-bucket/uploads/*` are not supported.
* The policy is 2048 bytes or less.

The credential gets exactly the actions you list. A credential with only `s3:GetObject` cannot list the bucket; add `s3:ListBucket` for that.

| Read actions                    | Write actions                   |
| ------------------------------- | ------------------------------- |
| `s3:GetObject`                  | `s3:PutObject`                  |
| `s3:GetObjectVersion`           | `s3:DeleteObject`               |
| `s3:GetObjectTagging`           | `s3:DeleteObjectVersion`        |
| `s3:GetObjectVersionTagging`    | `s3:PutObjectTagging`           |
| `s3:GetObjectAttributes`        | `s3:DeleteObjectTagging`        |
| `s3:ListBucket`                 | `s3:PutObjectVersionTagging`    |
| `s3:ListBucketVersions`         | `s3:DeleteObjectVersionTagging` |
| `s3:GetBucketLocation`          | `s3:AbortMultipartUpload`       |
| `s3:GetBucketVersioning`        | `s3:ListMultipartUploadParts`   |
| `s3:ListBucketMultipartUploads` |                                 |

Each action covers the same S3 operations as in an access key policy. See [supported actions](https://www.tigrisdata.com/docs/iam/policies/supported-actions.md).

The bucket must belong to the organization of the issuing access key. A bucket shared with you from another organization cannot be used with temporary credentials.

## Revoke temporary credentials[​](#revoke-temporary-credentials "Direct link to Revoke temporary credentials")

You cannot revoke one temporary credential. It ends when it expires. To end credentials early:

* Disable or delete the access key that issued them. This ends every credential that key issued, within about 10 minutes. Their requests then fail with `InvalidToken`.
* Reduce the issuing key's access. The credentials lose the access the key loses, within up to 30 minutes.

tip

Keep the lifetime short for credentials you hand to systems you do not control.

## Not supported[​](#not-supported "Direct link to Not supported")

* `AssumeRole`, `AssumeRoleWithWebIdentity`, `AssumeRoleWithSAML`, and `GetSessionToken`
* The `PolicyArns` and `Tags` parameters of `GetFederationToken`
