Overview
TheS3Bucket construct provides secure object storage with SSL enforcement, auto-cleanup, and optional versioning. Configure a single class for all use cases: private storage, website hosting, and public read access.
Resource Class
Basic Usage
Standard Private Bucket
Website Hosting Bucket
Public Read Bucket
Default Behaviour
Configuration Options
Core Properties
All standard CDK
BucketProps are also supported.
WebsiteHostingConfig
Use Cases
Private Application Storage
The default configuration creates a private bucket with SSL enforcement.Static Website Hosting
SetwebsiteHosting to enable S3 website hosting. This automatically enables public read access and disables block public access settings.
Public Asset Delivery
SetpublicReadAccess: true for publicly readable buckets. This disables block public access settings.
Versioned Bucket with Backup Tier
WhenbackupVaultTier is set to “resilient” or “enterprise”, versioning is automatically enabled with a 30-day noncurrent version expiration lifecycle rule.
Advanced Configuration
Encryption
Lifecycle Rules
Event Notifications
Access Control
Bucket Policies
IAM Permissions
CORS Configuration
Monitoring
Access Logging
Complete Example
Best Practices
- Enable versioning for data protection when needed
- Use encryption for sensitive data
- Configure lifecycle rules to reduce costs
- Enable access logging for security audits
- Use least privilege IAM policies
- Use
websiteHostinginstead of manual website configuration - Use
publicReadAccessinstead of manual policy changes
Next Steps
ECR Repository
Store container images alongside object storage
Lambda Function
Process objects on upload with event notifications
IAM Role
Grant least-privilege access to bucket objects
Storage Factory
Create buckets with the StorageFactory pattern