How to automatically store images on AWS-S3?
This guide explains how to configure your Sylius 2.x store to automatically upload and store images (such as product images) on Amazon Web Services (AWS) S3. Using S3 storage reduces server load, improves performance, and provides scalability for your images.
Prerequisites
Make sure you have:
A working Sylius 2.x project
An AWS account with S3 access
Familiarity with Symfony configuration
1. IAM Setup & S3 Configuration
1.1 Create an IAM User for S3
Log in to the AWS Console
Go to IAM > Users > Add user
Set the User name, e.g.,
sylius-s3-mediaEnable Programmatic access
Click Next: Permissions
Choose Attach policies directly β click Create policy
Choose the JSON tab and paste:

Name and create the policy (e.g.,
SyliusS3AccessPolicy)Return to user creation β attach the policy β finish and download credentials
1.2 Configure your AWS CLI client
This is only needed if you want to use AWS CLI!
Enter your:
AWS Access Key ID
AWS Secret Access Key
Default region (e.g.,
eu-west-3)Default output format (e.g.,
json)
You can generate your keys on the AWS Console panel
![]()
1.3 Create an S3 Bucket
After sucessful setup of access keys you will be able to create the bucket
if you prefer to do it outside of the cli, you can achieve the same using AWS Console
![]()
1.4 Configure Bucket Policy (for public read access)

2. Symfony & Flysystem Configuration
Install Required Packages
Add AWS env variables
Add these variables to your .env file:
Configure AWS Client
Create config/services.yaml:
Configure Flysystem
Critical Note
The prefix must be empty ('') to avoid path conflicts with LiipImagine's cache_prefix configuration.
3. LiipImagineBundle Configuration
Update config/packages/liip_imagine.yaml:
4. Testing
Clear Cache
Test the configuration
Run the Sylius fixtures to check if the images are correctly loaded
Testing the Configuration using AWS CLI
Test S3 Upload
Test Image Generation
Create a test command to verify image processing:
Run the test:
Debugging Commands
Verify Your Setup
Log in to your AWS console and open your S3 bucket.
Check if the uploaded images appear under the configured folder (
media/image).

Troubleshooting
Access Denied Errors: Ensure your IAM user has sufficient permissions (
s3:PutObject,s3:GetObject,s3:DeleteObject). See AWS IAM Documentation for more.

Region Issues: Confirm your bucket region matches your AWS configuration.
Images Not Uploading: Ensure environment variables (
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_BUCKET) are correctly defined.
Further Reading
βAWS S3 Documentationβ
βSymfony Flysystem Bundleβ
Congratulations! You've successfully configured automatic image storage with AWS S3 in your Sylius application.
Last updated
Was this helpful?
