How to Do AWS S3 Storage on Claude Code (Step-by-Step Guide)

In this article

The fastest way to add AWS S3 storage to your project with Claude Code is to open your terminal, run claude, describe what you want to store, and let Claude scaffold the SDK setup, bucket permissions, and upload logic for you. This workflow suits developers building file upload features, static asset pipelines, or backup systems. The trade-off: Claude Code accelerates boilerplate but you still need valid AWS credentials and IAM permissions configured locally.

  • Claude Code can generate complete S3 integration code (SDK install, env vars, upload/download helpers) in a single prompt
  • AWS S3 offers 5 GB of free storage in the first 12 months via the AWS Free Tier
  • Proper IAM scoping (least-privilege) is critical; Claude Code will prompt you for it if you describe your use case clearly

What is AWS S3 and why use it with Claude Code?

Amazon S3 (Simple Storage Service) is an object storage service that lets you store and retrieve any amount of data. Common use cases include user file uploads, static website hosting, application logs, media storage, and database backups. According to AWS, S3 is designed for 99.999999999% (11 nines) of durability.

Claude Code is Anthropic's AI coding assistant that runs in your terminal. Instead of copying boilerplate from Stack Overflow or hunting through AWS SDK docs, you describe what you need in plain language and Claude writes the integration directly in your codebase. For S3, that means bucket configuration, presigned URLs, multipart uploads, and more, with your existing file structure intact.

Prerequisites before you start

Before running any Claude Code prompts, make sure you have the following in place:

  • An AWS account (free tier is sufficient for getting started)
  • AWS CLI installed and configured (aws configure) with an access key and secret
  • An IAM user or role with S3 permissions (s3:PutObject, s3:GetObject, s3:DeleteObject at minimum)
  • Claude Code installed (npm install -g @anthropic-ai/claude-code) and authenticated
  • A Node.js, Python, or other supported project already initialized

If you are unsure how to scope IAM permissions, simply tell Claude Code your use case (e.g., "users upload profile images") and it will generate a least-privilege IAM policy document you can attach directly in the AWS console.

How to set up AWS S3 storage in Claude Code: step by step

Step 1: open Claude Code in your project directory

Navigate to your project root and launch Claude Code:

cd my-project
claude

Claude Code reads your existing file structure so it can place generated files in the right locations and match your existing code style.

Step 2: install the AWS SDK

Ask Claude Code to install and configure the AWS SDK v3 for your runtime. For a Node.js project:

Install the AWS SDK v3 S3 client for this project and create a reusable S3 client helper that reads credentials from environment variables.

Claude Code will run npm install @aws-sdk/client-s3, create an src/lib/s3.ts (or equivalent) file, and wire up the client using AWS_REGION, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY from your .env.

Step 3: configure environment variables

Tell Claude Code to scaffold your .env file and add S3-specific variables:

Add the required AWS S3 environment variables to .env.example and update the env validation schema.

Typical variables include:

  • AWS_REGION (e.g., us-east-1)
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_S3_BUCKET_NAME

For managing env files cleanly across environments, see the guide on env file management on Claude Code.

Step 4: create your S3 bucket (via Claude Code or AWS console)

You can ask Claude Code to generate the AWS CLI commands to create and configure a bucket:

Write the AWS CLI commands to create an S3 bucket in us-east-1 with versioning enabled and public access blocked.

Claude Code will produce commands like:

aws s3api create-bucket --bucket my-app-uploads --region us-east-1
aws s3api put-bucket-versioning --bucket my-app-uploads --versioning-configuration Status=Enabled
aws s3api put-public-access-block --bucket my-app-uploads --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true

For a deeper walkthrough of bucket setup including CORS and lifecycle rules, see AWS S3 bucket setup on Claude Code.

Step 5: generate upload and download helpers

Describe your upload requirements to Claude Code:

Create a file upload service that accepts a Buffer and filename, uploads to S3, and returns a presigned URL valid for 1 hour.

Claude Code will generate a complete service file using PutObjectCommand and GetSignedUrlCommand, with proper error handling and TypeScript types if applicable. For handling the front-end side of file uploads, the guide on file uploads on Claude Code covers multipart form handling and progress tracking.

Step 6: write an integration test

Ask Claude Code to generate a test that confirms your S3 connection works:

Write a Jest test that uploads a small text file to S3 and verifies it can be retrieved, then deletes it.

This catches credential issues and bucket policy misconfigurations before they hit production.

Useful Claude Code prompts for S3 workflows

Beyond basic setup, Claude Code can handle more advanced S3 patterns. Here are prompts that work well:

TaskExample Prompt
Presigned upload URLs"Generate a presigned S3 PUT URL that expires in 15 minutes so clients can upload directly from the browser"
Multipart upload for large files"Implement multipart S3 upload for files over 100MB with progress events"
Image optimization pipeline"After upload to S3, trigger a Sharp resize to generate thumbnail and store alongside original"
Static site hosting"Configure this S3 bucket for static website hosting with a custom error page"
Lifecycle rules"Add a lifecycle rule to move objects to S3 Glacier after 90 days"
IAM policy generation"Write a least-privilege IAM policy for an app that only uploads to the /uploads prefix"

How to use slash commands and skills to speed up S3 workflows

Claude Code's slash commands let you run frequent operations faster. You can create a custom /s3-upload command that wraps your upload service, reducing the need to re-explain the context each session.

For reusable, shareable workflows, Claude Code Skills allow you to package S3 helpers as installable extensions. Teams working across multiple projects can share a single S3 skill that standardizes bucket naming conventions, tagging, and error handling.

You can also use the /usage command to check how many tokens your S3 scaffolding session consumed, keeping you aware of your usage before you hit a limit mid-task.

Avoiding the 5-hour lockout while building S3 integrations

S3 integrations involve multiple back-and-forth iterations: bucket setup, IAM debugging, CORS configuration, and testing. These sessions burn through Claude Code usage quickly. If you hit your usage limit mid-integration, you face a lockout that can last up to 5 hours, right when you are in the middle of debugging a presigned URL issue or a missing permission.

Usagebar sits in your macOS menu bar and shows your Claude Code usage in real time. It fires smart alerts at 50%, 75%, and 90% of your limit so you know exactly when to wrap up a session or save your progress. Credentials are stored securely in macOS Keychain. It's available on a pay-what-you-want model, with a free option for students.

Knowing your reset window is just as important: see when Claude Code usage resets so you can plan heavier sessions around your reset time instead of discovering the limit at the worst moment.

Get Usagebar - instant download, flexible pricing, and stay in flow through your entire S3 setup.

Key takeaways

  1. Set up AWS credentials and IAM permissions locally before starting a Claude Code session
  2. Use natural language prompts to have Claude Code install the SDK, create client helpers, and scaffold upload/download services
  3. Ask Claude Code to generate the AWS CLI bucket creation commands including versioning and public access blocks
  4. Use slash commands or Skills to package reusable S3 workflows across projects
  5. Generate presigned URLs for direct browser-to-S3 uploads to avoid routing large files through your server
  6. Monitor your Claude Code usage with Usagebar to prevent lockouts during long integration sessions

Sources

Never Get Locked Out Mid-Task Again

Never hit your usage limits unexpectedly. Usagebar lives in your menu bar and shows your 5-hour and weekly limits at a glance.

Get Usagebar

$9 — one-time, lifetime updates