Skip to main content
The S3 resource mounts an Amazon S3 bucket (or any S3-compatible service) at some prefix such as /s3/. All operations involve network I/O to the remote object store. Uses aioboto3 for async S3 access. Compatible with: AWS S3, MinIO, Cloudflare R2, Supabase Storage, DigitalOcean Spaces, and any S3-compatible service.

Config

S3Resource(config) takes an S3Config object with the bucket name and optional credentials, endpoint, and connection settings. Both READ and WRITE modes are supported.

Filesystem Layout

The S3 resource maps S3 object keys to virtual paths under the mount prefix. S3 “directories” are prefix-based - there are no real directory objects. For example, if bucket my-bucket contains:
Then mounting at /s3/ exposes:
Path mapping: virtual /s3/data/file.txt maps to S3 key data/file.txt.

Cache

The S3 resource uses IndexCacheStore with index_ttl = 600 (10 minutes). Directory listings are cached for up to 600 seconds before being refreshed from S3. This reduces API calls for repeated directory traversals.

Example

Shell Commands

The S3 resource supports the full set of shell commands since it operates on real file content (text, binary, JSON, CSV, etc.). Large files benefit from range reads to avoid downloading entire objects.

Read Commands

Text Processing

File Operations

Path Utilities

Compression

Encoding

Data Format Support

Commands with format-specific variants for structured data files: These variants auto-detect the format by extension and convert to tabular text (CSV) for processing.

Use Cases

  • AI agents accessing cloud data: Mount S3 buckets for agents to read and process remote datasets
  • Data pipelines: Read and write S3 objects with shell-like commands
  • Sandboxed cloud storage access: Restrict agent operations to a specific bucket and prefix
  • FUSE mounting: Expose S3 buckets through a virtual FUSE mount for external tools

Scoping a resource to a key prefix

Pass key_prefix: str | None = None to S3Config to transparently scope every operation to a subpath of the bucket:
When set, every read/write/list/stat/copy/rename/delete operation is transparently scoped to that bucket subpath. Agents see clean paths like /data/notes.md; the underlying bucket key is users/{user_id}/data/notes.md. Useful for multi-tenant systems. Pairs naturally with STS AssumeRole session policies for AWS-side enforcement. Unset behavior is unchanged. Normalization: leading slashes are stripped and a trailing slash is added automatically. Both None and an empty string are treated as “no prefix.”