# tigris credentials temporary

Issue [temporary credentials](https://www.tigrisdata.com/docs/iam/temporary-credentials.md) limited to one bucket and the actions you choose. You get an access key ID, a secret, and a session token. They expire on their own and you cannot revoke them one by one.

**Alias:** `temp`

## Usage[​](#usage "Direct link to Usage")

```
tigris credentials temporary [bucket] --name <name> [flags]

t3 creds temp [bucket] --name <name> [flags]
```

## Flags[​](#flags "Direct link to Flags")

| Name               | Required | Default  | Description                                                                                                                                                     |
| ------------------ | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bucket`           | No       | —        | The bucket the credentials work on. Required unless you pass `--policy`                                                                                         |
| `--name`, `-n`     | Yes      | —        | A name for the credentials. It appears in the federated user ARN. 2 to 32 characters from letters, digits, and `_+=,.@-`                                        |
| `--access`, `-a`   | No       | —        | Grant the read actions, the write actions, or both. Options: `read`, `write`, `readwrite`                                                                       |
| `--actions`        | No       | —        | Comma-separated actions to grant, such as `s3:GetObject,s3:ListBucket`. Combines with `--access`                                                                |
| `--policy`         | No       | —        | Path to a JSON policy to use instead of a bucket with `--access` or `--actions`. You cannot combine it with them                                                |
| `--duration`, `-d` | No       | `1h`     | How long the credentials last, from `15m` to `36h`. For example `30m`, `1h`, or `3600` (seconds)                                                                |
| `--export`         | No       | —        | Print the credentials as shell `export` lines and nothing else on stdout, for `eval "$(tigris credentials temporary ... --export)"`                             |
| `--for`            | No       | `tigris` | Which SDK the `--export` variables are for. `tigris` writes `TIGRIS_STORAGE_*`; `aws` writes `AWS_*` plus Tigris endpoints and region. Options: `tigris`, `aws` |

You must choose what to grant with `--access`, `--actions`, or `--policy`. The actions you can grant and the policy rules are in [Temporary credentials](https://www.tigrisdata.com/docs/iam/temporary-credentials.md#policy).

`read` grants the read actions, including `s3:ListBucket`. `write` grants only the object write actions, so write-only credentials cannot list the bucket.

## Examples[​](#examples "Direct link to Examples")

```
# Read-only credentials for one bucket, for one hour

tigris credentials temporary my-bucket --name reader --access read



# Upload credentials for a CI job, for 30 minutes

tigris credentials temporary my-bucket --name ci-upload --access write --duration 30m



# Exact actions

tigris credentials temporary my-bucket --name lister --actions s3:GetObject,s3:ListBucket



# A complete policy from a file

tigris credentials temporary --name custom --policy ./policy.json



# Put the credentials straight into the current shell

eval "$(tigris credentials temporary my-bucket --name dev --access readwrite --export)"



# Name the variables for the AWS SDK and the AWS CLI

eval "$(tigris credentials temporary my-bucket --name dev --access readwrite --export --for aws)"
```

## Which access key issues the credentials[​](#which-access-key-issues-the-credentials "Direct link to Which access key issues the credentials")

Tigris issues temporary credentials only with an access key. The command uses the access key the CLI uses: from `tigris login credentials`, `tigris configure`, the `TIGRIS_STORAGE_ACCESS_KEY_ID` and `TIGRIS_STORAGE_SECRET_ACCESS_KEY` environment variables, or an AWS profile.

The credentials can do only what both their policy and the issuing access key allow. If you disable or delete the issuing access key, all the credentials it issued stop working.

### When you are logged in with OAuth[​](#when-you-are-logged-in-with-oauth "Direct link to When you are logged in with OAuth")

An OAuth login cannot issue temporary credentials. If you are logged in with `tigris login oauth`, the command asks what to do:

* **Create a new access key for the bucket.** The CLI creates an access key with the same name as the credentials. The key gets the `ReadOnly` role on the bucket when you grant only read actions, and the `ReadWrite` role otherwise. It does not get the [default allowed operations](https://www.tigrisdata.com/docs/iam/manage-access-key.md#default-allowed-operations). The CLI does not save the key. Keep it until the credentials expire, then delete it with `tigris access-keys delete <id>`. If the credentials are not issued, the CLI deletes the key.
* **Cancel.** Log in with an access key with `tigris login credentials`, or set the access key environment variables, and run the command again.

note

Without a terminal, for example in CI, the command does not ask and fails. It also fails with `--policy`, because a policy can name any bucket.

## Use temporary credentials with the CLI[​](#use-temporary-credentials-with-the-cli "Direct link to Use temporary credentials with the CLI")

The CLI uses temporary credentials when it finds a session token next to an access key:

* `TIGRIS_STORAGE_SESSION_TOKEN` with `TIGRIS_STORAGE_ACCESS_KEY_ID` and `TIGRIS_STORAGE_SECRET_ACCESS_KEY`
* `AWS_SESSION_TOKEN` with `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
* An AWS profile that has `aws_session_token`

```
eval "$(tigris credentials temporary my-bucket --name dev --access read --export)"

tigris whoami                       # Credentials: temporary

tigris ls my-bucket

tigris credentials test --bucket my-bucket
```

note

Temporary credentials work only on objects in their bucket. Commands that list or manage buckets, access keys, or IAM fail with a message that explains this. `tigris credentials test` needs `--bucket` with temporary credentials.
