This Python script counts the number of objects in an S3-compatible object storage bucket. It supports both hardcoded credentials and command-line arguments for flexibility.
- Connects to an S3-compatible object storage.
- Counts the number of objects in a specified bucket.
- Supports command-line arguments for dynamic configuration.
- Uses
boto3
for AWS S3 API interactions.
- Python 3.x
boto3
andbotocore
libraries- dotenv
pip install boto3 botocore python-dotenv
Or alternatively usign uv:
uv init
uv sync
You can run the script with default values or override them using command-line arguments.
Modify the script to set your storage credentials and bucket name, then execute:
python count_objects.py
Or alternatively usign uv:
uv run count_objects.py
You can override the default values with:
python count_objects.py -b <bucket-name> -a <api-url> -k <access-key> -s <secret-key>
Argument | Description |
---|---|
-b , --bucket |
Name of the bucket (default: set in script) |
-a , --api-url |
S3-compatible storage URL (default: set in script) |
-k , --key |
Access key for authentication (default: set in script) |
-s , --secret |
Secret key for authentication (default: set in script) |
python count_objects.py -b mybucket -a https://s3.example.com -k myAccessKey -s mySecretKey
This project is licensed under the MIT License.