limegreentangerine / aws_storage
Adds S3 storage options to Concrete CMS
Package info
github.com/limegreentangerine/aws_storage
Type:concrete5-package
pkg:composer/limegreentangerine/aws_storage
Requires
- php: ^8.4
- aws/aws-sdk-php: ^3.395
- league/flysystem-aws-s3-v3: ^1.0
- limegreentangerine/class_kit: ^2.0
Requires (Dev)
- concrete5/core: ^9.5
- friendsofphp/php-cs-fixer: ^3.95
- phpunit/phpunit: ^13.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
AWS Storage adds an Amazon S3 storage location type to Concrete CMS. It lets you use an S3 bucket for file storage, optionally serve public file URLs through CloudFront, and queue file moves between storage locations. It also includes AWS API integration to automatically create S3 buckets, IAM users, policies, and CloudFront distributions directly from the Concrete CMS dashboard.
Requirements
- Concrete CMS 9.5 or later
- PHP 8.4 or later in the PHP 8.x series
- An Amazon S3 bucket and AWS credentials with the permissions needed by your site (or use the AWS API integration to create them automatically)
Composer installs the AWS SDK for PHP, Flysystem's AWS S3 adapter, and the class_kit package as dependencies.
Installation
-
Add this package to your Concrete CMS site's
packages/aws_storagedirectory using your usual package deployment method. -
From the Concrete CMS project root, install the site's Composer dependencies:
composer install
If you add this package to an existing site, update the site's Composer dependencies as appropriate for your deployment.
-
Install AWS Storage from the package list in the Concrete CMS dashboard.
Installation registers the S3 Storage storage type and adds the AWS Storage dashboard page at /dashboard/aws_storage.
Configure an S3 storage location
In the Concrete CMS dashboard, open System & Settings → Files → Storage Locations, then add a storage location using S3 Storage. Configure:
| Setting | Description |
|---|---|
| Storage Bucket | Required S3 bucket name. |
| CloudFront URL | Optional public base URL used to generate file URLs instead of the S3 object URL. |
| Access Key | Required AWS access key ID. |
| Access Secret | Required AWS secret access key. |
| Amazon S3 Region | Required region for the bucket, such as eu-west-2 or us-east-1. |
| API Version | AWS SDK API version; defaults to 2006-03-01. |
The configuration defaults an empty region to eu-west-2. Use credentials with only the access the site needs, and keep them private.
When a CloudFront URL is configured, the package appends the file path to that URL. For example, a base URL of https://cdn.example.com and a file path of images/photo.jpg produce https://cdn.example.com/images/photo.jpg. If no CloudFront URL is set, the package uses the S3 object URL generated by the AWS SDK.
Create AWS resources with AWS API integration
The AWS Storage dashboard provides an automated setup wizard to create AWS resources directly from Concrete CMS:
- Open
/dashboard/aws_storage. - Use the setup wizard to provide your AWS account credentials.
- The package will automatically:
- Create an S3 bucket with your specified name
- Create an IAM user with appropriate permissions
- Create and attach necessary IAM policies
- Optionally create a CloudFront distribution for CDN delivery
- Review the created resources and configure your storage location with the generated credentials.
All AWS API operations are logged for troubleshooting and audit purposes.
Move files between storage locations
The AWS Storage dashboard page can queue a move from one storage location to another:
- Ensure at least two storage locations are configured.
- Open
/dashboard/aws_storage. - Choose the current location and target location, then select Create Queue.
- Follow the resulting batch in the Concrete CMS activity dashboard.
Invalidate CloudFront cache
When using CloudFront to serve public files, you can invalidate cached content from the AWS Storage dashboard:
- Open
/dashboard/aws_storage. - Select the Invalidate URLs tab.
- Specify the file paths or URL patterns to invalidate.
- Submit the invalidation request.
CloudFront invalidations help ensure that updated files are served to users immediately rather than being served from the cache. Note that CloudFront charges for invalidation requests beyond a certain monthly quota.
Logging
AWS Storage operations can be logged for debugging and troubleshooting. Logging is disabled by default and must be explicitly enabled via an environment variable.
Enable logging
Create a .env file in your project root (or copy from .env.example):
cp .env.example .env
Then set the environment variable:
AWS_STORAGE_LOG=true
When enabled, the package logs:
- File operations (write, read, delete, rename, copy, etc.)
- S3 adapter creation and configuration
- URL generation for public files
- Any errors encountered during these operations
Disable logging
To disable logging, set the variable to false or remove the .env file:
AWS_STORAGE_LOG=false
Logging is disabled by default, and disabling it eliminates any logging performance overhead.
Development
Run the PHPUnit suite from the package directory:
composer install
composer test
License
Released under the MIT License. See LICENSE.TXT.