Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CrewAIInc CrewAI S3 Writer Tool

From Leeroopedia
Knowledge Sources
Domains Cloud_Integration, AWS_S3, File_IO
Last Updated 2026-02-11 00:00 GMT

Overview

Concrete tool for writing content to Amazon S3 buckets provided by CrewAI.

Description

The S3WriterTool class extends BaseTool and uses the boto3 S3 client to upload content to Amazon S3. It parses S3 paths in the standard s3://bucket-name/object-key format to extract the bucket name and object key. The tool connects to AWS using credentials from environment variables (CREW_AWS_REGION, CREW_AWS_ACCESS_KEY_ID, CREW_AWS_SEC_ACCESS_KEY) with a default region of us-east-1. Content is encoded as UTF-8 and uploaded using put_object(). On success, it returns a confirmation message; on failure, it returns a descriptive error string. This tool complements S3ReaderTool to provide full read-write capabilities for S3-based workflows.

Usage

Import and use S3WriterTool when CrewAI agents need to persist results, reports, processed data, or any text output to Amazon S3 storage. It abstracts away the complexity of S3 API interactions and AWS authentication.

Code Reference

Source Location

  • Repository: CrewAI
  • File: lib/crewai-tools/src/crewai_tools/aws/s3/writer_tool.py
  • Lines: 1-50

Signature

class S3WriterTool(BaseTool):
    name: str = "S3 Writer Tool"
    description: str = "Writes content to a file in Amazon S3 given an S3 file path"
    args_schema: type[BaseModel] = S3WriterToolInput
    package_dependencies: list[str] = Field(default_factory=lambda: ["boto3"])

Import

from crewai_tools.aws.s3 import S3WriterTool

I/O Contract

Inputs

Name Type Required Description
file_path str Yes S3 file path in format "s3://bucket-name/object-key"
content str Yes Content to write to the file

Outputs

Name Type Description
return str Success confirmation message ("Successfully wrote content to {path}") or an error message string on failure

Usage Examples

Basic Usage

from crewai_tools.aws.s3 import S3WriterTool

# Initialize the tool
writer = S3WriterTool()

# Write content to S3
result = writer._run(
    file_path="s3://my-bucket/output/report.txt",
    content="Analysis results: Revenue increased by 15%.",
)
print(result)  # "Successfully wrote content to s3://my-bucket/output/report.txt"

Combined Read/Write Workflow

import os
from crewai_tools.aws.s3 import S3ReaderTool, S3WriterTool

os.environ["CREW_AWS_REGION"] = "us-west-2"
os.environ["CREW_AWS_ACCESS_KEY_ID"] = "your-key-id"
os.environ["CREW_AWS_SEC_ACCESS_KEY"] = "your-secret-key"

reader = S3ReaderTool()
writer = S3WriterTool()

# Use both tools with a CrewAI agent
agent = Agent(
    role="data_processor",
    tools=[reader, writer],
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment