Quick test program to verify AWS S3 bucket creation and file upload functionality.
- Creates a uniquely named S3 bucket (using timestamp)
- Uploads a test file to the bucket
- Verifies the file exists
- Downloads and verifies the content matches (SHA256 hash)
- Cleans up by deleting the file and bucket (optional)
Install boto3:
pip install boto3Or if using the project's S3 optional dependencies:
uv pip install -e ".[s3]"Configure AWS credentials using one of these methods:
aws configureexport AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key
export AWS_DEFAULT_REGION=us-east-1export AWS_PROFILE=your-profile-nameIf running on EC2/ECS/Lambda, IAM roles are automatically detected.
python test_aws_s3.pyThis will:
- Create a bucket with name like
putplace-test-20251016-143022 - Upload a test file
- Verify the upload
- Delete the file and bucket
python test_aws_s3.py --keep-bucketpython test_aws_s3.py --region us-west-2======================================================================
AWS S3 Test Program
======================================================================
[1/7] Initializing S3 client (region: us-east-1)...
✓ Successfully connected to AWS S3
[2/7] Generated unique bucket name: putplace-test-20251016-143022
[3/7] Created test file: test-file-abc12345.txt
Content: Hello from PutPlace S3 test!
Size: 30 bytes
SHA256: abc123...
[4/7] Creating S3 bucket: putplace-test-20251016-143022...
✓ Bucket created successfully
[5/7] Uploading file to bucket...
✓ File uploaded successfully: s3://putplace-test-20251016-143022/test-file-abc12345.txt
[6/7] Verifying file exists...
✓ File exists!
ETag: "abc123..."
Size: 30 bytes
Last Modified: 2025-10-16 14:30:25+00:00
[7/7] Downloading and verifying content...
✓ Content verified successfully!
Original SHA256: abc123...
Downloaded SHA256: abc123...
Content matches: Hello from PutPlace S3 test!
======================================================================
SUCCESS! All tests passed!
======================================================================
======================================================================
Cleanup
======================================================================
Deleting file: test-file-abc12345.txt...
✓ File deleted
Deleting bucket: putplace-test-20251016-143022...
✓ Bucket deleted
✓ Cleanup complete!
Configure credentials using one of the methods above.
Ensure your AWS credentials have permissions for:
s3:CreateBuckets3:PutObjects3:GetObjects3:DeleteObjects3:DeleteBuckets3:ListBucket
The script generates unique bucket names, but if you get this error, try running again (it includes timestamp with seconds).
If the script fails and doesn't clean up:
# Delete file
aws s3 rm s3://putplace-test-YYYYMMDD-HHMMSS/test-file-*.txt
# Delete bucket
aws s3 rb s3://putplace-test-YYYYMMDD-HHMMSSThis test script validates the same AWS S3 operations that PutPlace uses in its S3 storage backend (src/putplace/storage.py). If this test passes, your AWS credentials are properly configured for PutPlace's S3 storage feature.