A command-line utility to create and manage short URLs backed by S3 objects. Each shortcode is stored as an S3 object whose content is the target long URL.
mkurl stores shortcodes as plain-text objects in an S3 bucket:
s3://<BUCKET>/<PREFIX><shortcode> → contents: "https://long-url.example.com"
A separate URL expander (running on your web server) reads these objects to perform the actual redirects.
Edit the constants near the top of the mkurl script:
BUCKET = "your-bucket-name" # S3 bucket holding the shortcodes
PREFIX = "urls/" # S3 key prefix
BASE_URL = "http://hpc.news/" # Base URL of your expander service
RANDOM_DIGITS = 3 # Digits appended in -R mode (wordNNN)chmod +x mkurl
cp mkurl ~/bin/ # or /usr/local/bin, anywhere on your PATH
pip install boto3 # if not already installedAWS credentials are resolved via the standard boto3 chain
(~/.aws/credentials, environment variables, IAM role, etc.).
mkurl -s goog -l https://google.com
# → http://hpc.news/googmkurl -s goog -l https://google.co.uk -F
# → http://hpc.news/googmkurl -R news -l https://example.com/some/long/path
# → http://hpc.news/news042 (or whatever unused wordNNN is found)Output is TSV: shortcode <tab> short URL <tab> long URL
mkurl -L
# goog http://hpc.news/goog https://google.com
# news042 http://hpc.news/news042 https://example.com/some/long/pathmkurl -L goog
# goog http://hpc.news/goog https://google.com| Flag | Description |
|---|---|
-s SHORTCODE |
Explicit shortcode to create |
-l URL |
Long URL to store (required when creating) |
-R WORD |
Generate a random shortcode of the form WORDnnn |
-F |
Force-overwrite an existing shortcode |
-L [SHORTCODE] |
List all mappings (sorted), or one specific one |