Why Connect S3 to Odoo?
By default, Odoo stores file attachments in the database or local filesystem. This works for small deployments but creates problems at scale — database bloat, slow backups, limited disk space, and no CDN integration. Amazon S3 (or S3-compatible storage like MinIO, Wasabi, or Backblaze B2) provides virtually unlimited, durable, and cost-effective storage for Odoo attachments.
What S3 Storage Handles
| Data Type | Typical Volume | S3 Benefit |
|---|---|---|
| File attachments | 1-100 GB | Offload from database, faster queries |
| Document scans | 10-500 GB | Unlimited storage, versioning |
| Product images | 1-50 GB | CDN-ready serving, image processing |
| Email attachments | 5-200 GB | Reduce mail server storage |
| Backup archives | 50-1000 GB | Lifecycle policies, cross-region replication |
Integration Methods
Method 1: Odoo ir.attachment S3 Backend
Replace Odoo's default attachment storage with S3:
- Install a community module that redirects ir.attachment to S3
- All new attachments stored in S3 automatically
- Existing attachments can be migrated with a script
- Transparent to users — upload/download works identically
Method 2: Custom S3 Module
Build a dedicated integration module:
- Use boto3 (AWS SDK for Python) in Odoo server actions
- Configure S3 bucket, access keys, and region as system parameters
- Handle upload, download, delete, and presigned URL generation
- Add S3 URL field to relevant models
Method 3: Backup Storage
Use S3 specifically for Odoo backups:
- Scheduled action runs pg_dump and uploads to S3
- S3 lifecycle policies manage retention (30-day active, 90-day glacier)
- Cross-region replication for disaster recovery
- Versioning for point-in-time recovery
Setup Steps
1. S3 Bucket Configuration
- Create an S3 bucket with a descriptive name (e.g., mycompany-odoo-attachments)
- Enable versioning for accidental deletion protection
- Configure server-side encryption (AES-256 or KMS)
- Set bucket policy to deny public access
- Enable access logging for audit compliance
2. IAM Configuration
- Create a dedicated IAM user for Odoo
- Attach a minimal policy: s3:PutObject, s3:GetObject, s3:DeleteObject, s3:ListBucket
- Restrict permissions to the specific bucket ARN
- Generate access key and secret key
- Consider using IAM roles instead of keys if running on EC2
3. Odoo Configuration
- Install S3 attachment module (community or custom)
- Configure system parameters: bucket name, region, access key, secret key
- Set S3 endpoint URL (for S3-compatible services)
- Configure base URL for public file access (if using CloudFront)
- Test upload and download with a sample file
4. Migration of Existing Attachments
- Write a migration script to copy existing filestore attachments to S3
- Update ir.attachment records to point to S3 locations
- Verify all attachments are accessible after migration
- Keep local filestore as backup during transition period
- Remove local copies only after thorough verification
Performance Optimization
- Use CloudFront CDN in front of S3 for faster downloads
- Generate presigned URLs for secure, time-limited access
- Use S3 Transfer Acceleration for faster uploads from distant locations
- Configure multipart upload for large files (100MB+)
- Implement client-side caching headers
Cost Management
- S3 Standard: ~$0.023/GB/month for frequently accessed files
- S3 Infrequent Access: ~$0.0125/GB/month for older attachments
- S3 Glacier: ~$0.004/GB/month for backup archives
- Set lifecycle rules to move old files to cheaper tiers automatically
- Monitor costs with AWS Cost Explorer
Common Pitfalls
- IAM permissions — Too broad permissions create security risks. Use least-privilege policies.
- CORS configuration — If serving files directly from S3 to browsers, configure CORS headers.
- Large file handling — Use multipart upload for files over 100MB to avoid timeouts.
- Bucket naming — Bucket names are globally unique. Use a consistent naming convention.
Getting Started
Deploy Odoo on DeployMonkey where S3 backup integration is configured automatically. For attachment storage, install a community S3 module and configure your bucket credentials. The AI agent can help set up the necessary Odoo configuration.