A Cloudflare Worker that waits for Oracle Cloud Always Free ARM capacity and claims it for you.
Oracle's free VM.Standard.A1.Flex tier is heavily oversubscribed. Clicking Create in the console usually fails with Out of capacity for shape VM.Standard.A1.Flex. Capacity frees up unpredictably, for seconds at a time, so the only reliable way to get an instance is to ask repeatedly.
This Worker does that on a one-minute Cron Trigger. When a slot opens, it creates the instance and messages you. No server of your own needs to run.
┌─────────────┐ every 60s ┌──────────────┐ signed HTTPS ┌────────────┐
│ CF Cron │ ────────────► │ Worker │ ───────────────► │ OCI API │
│ Trigger │ │ (this repo) │ │ │
└─────────────┘ └──────┬───────┘ └────────────┘
│ on success
▼
Telegram / Discord
The obvious alternative is a scheduled GitHub Actions workflow, which is also free. A Worker is a better fit:
| Cloudflare Worker | GitHub Actions cron | |
|---|---|---|
| Minimum interval | 60s | 5 min (best-effort, often late) |
| Cold-start overhead | ~0ms | 20–60s per run |
| Cost of polling | 1 request | A full runner boot |
A 60-second interval costs roughly 1,440 invocations a day, which is under 1.5% of the Workers free tier's 100,000 daily requests. Signing an OCI request takes about 0.3 ms of the 10 ms CPU allowance per invocation.
Each invocation makes exactly one LaunchInstance call, in this order:
- Check for an existing instance. If one matching
DISPLAY_NAMEis live, exit immediately. This makes the schedule safe to leave enabled. - Resolve resources once per isolate: availability domain, a public subnet with an internet route, and the newest ARM image for your chosen OS.
- Choose a size by rotating through
OCI_SIZESacross invocations. - Launch. Interpret the result: capacity (retry), throttle (retry), limit (stop and tell you), or success (notify).
OCI rate-limits launch_instance per tenancy. A second call issued moments after the first returns:
HTTP 429 TooManyRequests — "Too many requests for the tenant"
So a loop that tries several sizes back-to-back inside one run — the pattern most such scripts use — spends a large fraction of its attempts throttled rather than actually testing for capacity. Spacing attempts across invocations keeps every call useful.
The fallback exists because a smaller request needs less contiguous capacity, so it clears more often. But it cannot be tried immediately after the primary; see above. Instead the fallback runs on a share of invocations:
OCI_SIZES="2:12,1:6" → ~2/3 of runs ask for 2 OCPU/12 GB
~1/3 of runs ask for 1 OCPU/6 GB
The weighting favours the primary size, because the Always Free allowance is 2 OCPU / 12 GB total and a fallback instance leaves the remainder unused. Set OCI_SIZES to a single size if you would rather wait for one specific shape.
Profile menu → My profile → API keys → Add API key → Generate API key pair.
Download the private key (.pem), click Add, and note the four values from the configuration preview:
user ocid1.user.oc1..aaaa…
fingerprint 12:34:56:…
tenancy ocid1.tenancy.oc1..aaaa…
region ap-mumbai-1
Networking → Virtual Cloud Networks → Start VCN Wizard → Create VCN with Internet Connectivity.
Discovery finds the subnet automatically, but only one that routes 0.0.0.0/0 to an internet gateway. Set OCI_SUBNET_OCID to skip discovery.
ssh-keygen -t ed25519 -f oci_sniperYou will paste the contents of oci_sniper.pub into the Worker configuration. The private key never leaves your machine.
The Worker rejects values that look like a private key. An accidental paste of the wrong file is the most common way credentials leak into a deployment.
git clone https://github.com/nullstacks/oci-sniper.git
cd oci-sniper
npm install
npx wrangler login
npx wrangler deploy # create the Worker firstStore the secrets. wrangler secret put prompts for the value, which avoids the secret appearing in your shell history or process list:
npx wrangler secret put OCI_USER_OCID
npx wrangler secret put OCI_TENANCY_OCID
npx wrangler secret put OCI_FINGERPRINT
npx wrangler secret put OCI_PRIVATE_KEY # paste the whole .pem, BEGIN/END lines included
npx wrangler secret put SSH_PUBLIC_KEY # contents of oci_sniper.pubThen adjust the non-secret settings in wrangler.jsonc under vars, or leave the defaults:
| Variable | Default | Notes |
|---|---|---|
OCI_REGION |
(required) | Home region, e.g. ap-mumbai-1 |
DISPLAY_NAME |
free-arm-server |
Also the idempotency key |
OCI_SIZES |
2:12,1:6 |
Ordered OCPU:GB; index 0 is primary |
BOOT_VOLUME_GB |
50 |
|
OCI_OS_NAME |
Canonical Ubuntu |
|
OCI_OS_VERSION |
22.04 |
|
OCI_COMPARTMENT_OCID |
tenancy root | |
OCI_SUBNET_OCID |
auto | |
OCI_IMAGE_ID |
auto | Newest matching image |
OCI_AVAILABILITY_DOMAIN |
auto |
At least one is worth configuring; otherwise success is only visible in the log.
Telegram — message @BotFather, send /newbot, and keep the token. Then send your new bot any message, which is required before it can message you. Your chat ID can be read from https://api.telegram.org/bot<token>/getUpdates.
npx wrangler secret put TELEGRAM_BOT_TOKEN
npx wrangler secret put TELEGRAM_CHAT_IDDiscord — Server Settings → Integrations → Webhooks → New Webhook → copy URL.
npx wrangler secret put DISCORD_WEBHOOK_URLAnything else — NOTIFY_WEBHOOK_URL receives {"subject": "...", "body": "..."} as a POST.
npx wrangler deployThen trigger one attempt manually:
curl https://oci-sniper.<your-subdomain>.workers.dev/A healthy first response looks like:
{ "ok": true, "outcome": "capacity", "size": "2 OCPU/12 GB" }capacity means everything is wired correctly and Oracle simply has no room. Watch it live with:
npx wrangler tail| Request | Effect |
|---|---|
GET / |
One attempt, size chosen by rotation |
GET /?size=2x12 |
One attempt at a specific size |
GET /health |
Liveness probe |
Each manual call consumes the same rate-limit budget as a scheduled one, so avoid hammering these while the Cron Trigger is live.
outcome |
Meaning |
|---|---|
capacity |
No room right now. Working as intended. |
throttled |
OCI rate-limited this attempt. Will retry next run. |
created |
Instance accepted. Details sent to your channels. |
exists |
An instance with this name is already live. Nothing to do. |
limit |
Always Free quota already in use. Polling stops. |
error |
Unexpected response. Investigate. |
No hardcoded account values. Every OCID, key and region comes from the environment, so the repository is safe to host publicly.
Logs are redacted. redact() strips OCIDs, IPv4 addresses and email addresses from everything logged, so sharing a screenshot of wrangler tail does not disclose account details.
Transient failures are retried. Reads retry on 429, 5xx, and the occasional spurious 404 NotAuthorizedOrNotFound that OCI returns for resources that exist. Writes deliberately do not retry on 404, since a duplicate launch attempt is worse than a missed one.
Resource discovery is cached per isolate. A warm isolate skips three API calls per run.
Nothing is deleted on success. The schedule keeps running; each invocation costs one cheap existence check. Disable it whenever you like:
npx wrangler delete- One region per deployment. Free capacity exists only in your tenancy's home region.
- Single availability domain in some regions. Mumbai has one, so "try another AD" — the advice in Oracle's own error message — is not an option there.
- Timing is luck, not speed. If a slot is claimed within seconds by someone else, a 60-second poll will miss it. Polling faster than 60s mostly produces 429s.
- The egress IP is Cloudflare's. If your tenancy has an allow-list, this will not match it.
- The API key lives in Cloudflare. It is encrypted at rest, but it is still a third party holding a credential with tenancy access. Revoke it in the OCI console when you no longer need it.
Two things worth doing promptly:
Keep it active. Oracle reclaims Always Free A1 instances that are idle over a 7-day window — CPU utilisation below 20%, network below 20%, and memory below 20%. A freshly created 12 GB instance sitting idle is exactly the profile that gets reclaimed. Run something real on it.
Snapshot it. The free tier includes five volume backups, which do not count against the 200 GB block storage allowance.
| Symptom | Cause |
|---|---|
Missing required configuration |
A secret was not set, or was set on a different Worker |
401 NotAuthenticated |
Wrong fingerprint, or the key does not match it. Check that key_file and OCI_FINGERPRINT came from the same key pair |
404 NotAuthorizedOrNotFound after several retries |
No public subnet with an internet route, or credentials lack permission in the compartment |
Signature is invalid |
System clock drift. OCI rejects signatures more than five minutes off |
limit on the first run |
An A1 instance already exists, or boot volume storage is exhausted |
| No notification arrives | Telegram requires you to message the bot before it can message you. For Discord, verify the webhook URL |
npm test # signing and redaction tests
npx wrangler dev # local runtime
node scripts/smoke-test.js # one real attempt against your tenancyscripts/smoke-test.js reads ~/.oci/config (or OCI_CONFIG_PATH), performs a single launch attempt, and prints the result. Point DISPLAY_NAME at an existing instance to verify the whole path without creating anything.
MIT