Fly.ioProblem & solution
AWS without Access Keys
Summary
The post describes how Fly Machines can access AWS resources such as an S3 bucket without distributing long-lived AWS access keys. It uses OpenID Connect (OIDC): AWS IAM trusts Fly.io’s OIDC identity provider, a role grants narrowly scoped permissions, and the app receives the role ARN as an environment variable. At boot, Fly’s Rust init requests a machine-specific OIDC token through the /.fly/api Unix socket, writes it to /.fly/oidc_token, and sets AWS_WEB_IDENTITY_TOKEN_FILE and AWS_ROLE_SESSION_NAME so the AWS SDK can call STS AssumeRoleWithWebIdentity. AWS verifies the token, issues short-lived credentials, and evaluates the role’s IAM policy before serving the requested object. The trust policy can constrain tokens by audience and subject, including an organization, Fly App, or machine; the same pattern can authenticate against other OIDC-compliant providers, although Azure and GCP lack equivalent init integration.
Context
An app running on Fly.io needs access to large training data stored in an AWS S3 bucket, but distributing AWS user keypairs is presented as a serious cloud-security risk.
Approach / What changed
Configure AWS IAM to trust Fly.io’s OIDC identity provider and create a role with S3 permissions and token conditions. Set the role ARN as AWS_ROLE_ARN in the Fly App; Fly init obtains a machine-specific OIDC token and configures the AWS SDK to exchange it through STS for temporary credentials.
Takeaways
AWS STS credentials are generated dynamically, expire in minutes, rotate themselves, and fail closed, limiting the blast radius compared with stored AWS keypairs.
The IAM trust policy can restrict access by token audience and subject, including an organization, a specific Fly App, or an individual Fly Machine.
Fly’s OIDC support accepts arbitrary audience strings, allowing authentication to other OIDC-compliant cloud providers, though Azure and GCP do not have equivalent init integration described here.
Source and freshness
- Source
- fly.io
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.