Skip to content

flint

GitHub →

flint is a small CLI that issues temporary Amazon Bedrock bearer tokens from an AWS profile. It works like the assume command from granted.dev, but it issues a Bedrock API key instead of raw AWS credentials.

eval "$(flint my-profile)"
# AWS_BEARER_TOKEN_BEDROCK is now set; the Bedrock CLI and SDKs read it.
aws bedrock-runtime converse --model-id ... --region us-east-1

What flint does

A Bedrock short-term API key is not a server-issued resource. It is a SigV4 query-presigned request against bedrock.amazonaws.com. flint base64-encodes that request and adds the prefix bedrock-api-key-. The token comes from the credentials your profile resolves to:

  1. Resolve credentials through the standard AWS configuration chain (static keys, SSO, assume-role, environment variables).
  2. SigV4 query-presign the CallWithBearerToken action for your region.
  3. Encode the result into the bedrock-api-key-...&Version=1 token format.

The token inherits the permissions of the resolved principal, is locked to the region flint signed it for, and is valid for the shortest of three values: --duration, 12 hours, and the time left on the credentials (with a 5-minute floor). flint makes no privileged “issue key” API call — it derives the token on the client.

Install

# Homebrew (macOS and Linux)
brew install --cask madstone-tech/tap/flint

# Go
go install github.com/madstone-tech/flint/cmd/flint@latest

Or download an archive from GitHub Releases and put flint on your PATH. Confirm the install with flint --version.


Usage

The default output is a shell export line, so you can use it like assume:

eval "$(flint my-profile)"

Other modes:

flint --raw my-profile                     # print the token only
flint --json my-profile                    # {"token":...,"region":...,"expires":...}
flint --region us-west-2 my-profile        # set the region
flint --duration 1h my-profile             # set a shorter lifetime (5m–12h)
flint --exec my-profile -- python app.py   # run a command with the token in its environment

With --exec, flint propagates the child command’s exit code, so it acts as a transparent wrapper. It keeps the token out of your shell history.


Interactive profile picker

Run flint with no profile argument in an interactive terminal. flint opens a filterable picker listing the profiles from your ~/.aws/config and ~/.aws/credentials files:

flint                 # pick a profile, then print the export line
eval "$(flint)"       # pick a profile and export the token in one step

Type part of a profile name to filter, use the arrow keys to move, Enter to select, and Esc to cancel. flint draws the picker on stderr, so it never corrupts the token on stdout — eval "$(flint)" stays safe. Without a terminal (a pipe, a script, or CI), flint skips the picker; give a profile argument, or flint uses the default credential chain.


Shell integration

Add flint’s helpers to your ~/.bashrc or ~/.zshrc:

eval "$(flint shellenv)"

This defines two functions. It does not export a token at shell startup, which would freeze a token for up to 12 hours:

bedrock-auth my-profile                 # mint a token into the current shell, on demand
bedrock-run my-profile -- python app.py # run a command with the token in its environment only

List the profiles flint can see with flint profiles (alias ls), one per line.


Verifying a token

flint verify checks a token in two tiers.

The structural check runs offline and makes no AWS call. flint decodes the token and confirms the bedrock-api-key- prefix, the base64 payload, the &Version=1 suffix, the bedrock.amazonaws.com host, the SigV4 parameters, the region, and the signature window:

flint --raw my-profile | flint verify
structure: valid
  region:    us-east-1
  action:    CallWithBearerToken
  issued:    2026-10-29T15:00:00Z
  expires:   2026-10-30T03:00:00Z (in 11h59m)

The live check adds --live. It calls ListFoundationModels with the token to confirm Bedrock accepts it. The region must match the region flint signed the token for:

flint --raw my-profile | flint verify --live
# live:      accepted by Bedrock (HTTP 200) in us-east-1

flint reads the token from the positional argument first, then from piped stdin, then from the AWS_BEARER_TOKEN_BEDROCK environment variable. verify exits non-zero when the token is invalid, expired, or rejected, so it works in scripts. flint also detects a long-term Bedrock API key and reports that it handles short-term tokens only.


Logging and exit codes

flint is quiet by default. Pass --verbose for step-by-step diagnostic logs on stderr, and --log-format json for machine-readable logs. The logs carry only metadata (profile, region, expiry, output mode), never the token or any secret, so eval "$(flint --verbose my-profile)" stays safe.

Commands return stable exit codes, so scripts can branch on a failure:

CodeMeaning
0success
1generic error
2bad invocation (flags or arguments, or no token to verify)
3flint could not resolve credentials or a region
4the token is invalid, expired, or rejected
130the user cancelled (for example, the picker closed)

An error prints a one-line message, with a hint: line for the next step where it is useful. When a profile is not signed in, the hint is aws sso login --profile X.


CLI reference

CommandDescription
flint [profile]Issue a token; print a shell export line (the default)
flint verify [token]Validate a token structurally, or with --live against Bedrock
flint profiles (alias ls)List the discovered AWS profiles
flint shellenvPrint lazy shell helpers for eval "$(flint shellenv)"
flint versionPrint the build metadata

Flags on the default command:

FlagDescription
--rawPrint the token only
--jsonPrint {"token":...,"region":...,"expires":...}
--region <region>Set the region (otherwise resolved from the profile)
--duration <dur>Set the token lifetime, clamped to 5m–12h
--exec -- <cmd>Run a command with the token in its environment
--verboseStep-by-step diagnostic logs on stderr
--log-format <text|json>Choose the log format
--versionPrint build metadata

verify flag: --live probes Bedrock with ListFoundationModels to confirm acceptance.


Notes

  • The Bedrock SDKs and the AWS CLI read the AWS_BEARER_TOKEN_BEDROCK environment variable.
  • You cannot refresh or extend a token. When a token expires, generate a new one.
  • Store tokens in a safe place and do not log them. --exec keeps the token out of your shell history.

flint is MIT-licensed and maintained in the madstone-tech GitHub org. For issues and feature requests, visit the GitHub repository.