A small Dockerized wrapper around Terraform that continuously retries provisioning an Oracle Cloud Infrastructure (OCI) free‑tier instance when the target region reports "out of capacity", and stops once the instance is created successfully.
- Continuously attempts
terraform initandterraform applyuntil a run succeeds - Handles
initretries with-reconfigureand-upgradefallbacks - Designed to work with OCI free‑tier capacity errors (e.g., temporary "out of capacity")
- Docker (or Podman)
- Docker Compose (optional, for provided
docker-compose.yaml) - An OCI tenancy with API key (see
.env.example) - Terraform configuration files in
./terraformthat provision the desired instance
-
Copy the example env file and fill in your OCI details:
cp .env.example .env # Edit .env to set your OCIDs, region, and the private key path -
Store your OCI private key in the
keys/directory (file name and path must matchPRIVATE_KEY_PATHinside.env). For example:- Place
private-key.pemat./keys/private-key.pem - Set
PRIVATE_KEY_PATH=/root/.ssh/private-key.pemin.env
The compose file mounts
./keysto/root/.ssh(read-only) inside the container. - Place
-
Run with Docker Compose:
docker compose up -d docker compose logs -f oci-instance-creator
Or run the image directly:
docker run --rm -it \ -v "$(pwd)/terraform:/app/terraform" \ -v "$(pwd)/keys:/root/.ssh:ro" \ --env-file .env \ ghcr.io/pschmucker/oci-instance-creator:latest
- The container runs
loop-apply.sh, which:- Changes into
/app/terraform - Runs
terraform initwith fallbacks (-reconfigure,-upgrade) when necessary - Runs
terraform apply -auto-approvein a loop until it succeeds
- Changes into
- On success the container exits (so it won't keep running unnecessarily)
- View runtime logs:
docker logs -f oci-instance-creator(compose)
- Common problems:
- Incorrect OCIDs or fingerprint → Terraform/Oci provider errors
- Wrong
PRIVATE_KEY_PATHor missing key → auth failures - Provider reports "out of capacity" → this tool will retry until capacity appears
- Ensure private keys are readable only by you (
chmod 600 keys/private-key.pem).
Patches and improvements are welcome via pull requests. Please follow standard GitHub workflows.
This project is licensed under the MIT License. See the LICENSE file for details.