Skip to main content

Start cloud instances.

Project description

Spare Cores Runner

Spare Cores Runner is a command-line tool and Python API designed to simplify the process of provisioning and managing cloud instances across various cloud providers. It leverages Pulumi to handle infrastructure-as-code and automate the creation, and destruction of compute instances in your preferred cloud environment.

Spare Cores Runner (sc-runner from now on) is used by Spare Cores Inspector to start up basic cloud instances with the required minimum configuration and environment to start the machine with a custom cloud-init script, but it can be used to just start an instance with a given SSH key, so it's available for basic uses.

Supported Cloud Providers and their Credentials

sc-runner uses the Spare Cores database to pre-fill the available configuration options, like what regions and instance types are available for a given cloud provider. To use a given cloud provider, you have to provide credentials for them, either by running it in an environment, where the underlying library can pick them up, or by specifying them through environment variables or by command line options.

For more details, see the supported vendor's Pulumi integration:

Pulumi

As sc-runner uses Pulumi under the hood to manage the cloud providers, it'll need to have a Pulumi project. You can configure Pulumi project-related settings either by specifying them using command line arguments, shown below:

sc-runner create --help
Usage: sc-runner create [OPTIONS] COMMAND [ARGS]...

Options:
  --project-name TEXT        Pulumi project name  [default: runner]
  --work-dir TEXT            Pulumi work dir  [default: /data/workdir]
  --pulumi-home TEXT         Pulumi home  [default: /root/.pulumi]
  --pulumi-backend-url TEXT  Pulumi backend URL  [default: file:///data/backend]
  --stack-name TEXT          Pulumi stack name, defaults to
                             {vendor}.{region}.{zone}.{instance_id} or similar
  --help                     Show this message and exit.

Commands:
  aws
  azure
  gcp
  hcloud
  upcloud

Or by setting the following environment variables:

  • PULUMI_PROJECT_NAME
  • PULUMI_WORK_DIR
  • PULUMI_HOMEPULUMI_BACKEND_URL

sc-runner should create the project on the first invocation, in which it'll create multiple stacks for each vendor.region.zone.instance_id tuple. This is to allow concurrent creation of the instances, supporting our Spare Cores Inspector use case, where we start a given instance type once for collection data from them.

Usage

CLI examples

Create instances

Create and destroy a default t3.micro instance in the default VPC/subnet in AWS:

sc-runner create aws
sc-runner destroy aws

Create an Azure instance with a public key:

sc-runner create azure --instance Standard_DS1_v2 --public-key $(cat .ssh/id_ed25519.pub)

Create an AWS instance with public IP and an already stored SSH key named spare_cores:

sc-runner create aws --region us-west-2 --instance t4g.large --instance-opts '{"associate_public_ip_address": true,"key_name":"spare-cores"}' --public-key ""

Destroy instances

sc-runner destroy azure --instance Standard_DS1_v2
sc-runner destroy aws --region us-west-2 --instance t4g.large

You can also user destroy-stack instead of destroy, which does a pulumi refresh first, synchronizing the underlying cloud-reality with Pulumi's internal backend and destroys only what's really there (so it won't fail on already deleted resources).

Cancelling Pulumi Locks

Sometimes Pulumi might leave a lock file in its state store, preventing further operations. With this command you can cancel those:

sc-runner cancel aws --region us-west-2 --instance t4g.large

Docker

sc-runner is available through a Docker image as well, which you can use with the following command:

docker run --rm -ti ghcr.io/sparecores/sc-runner:main --help

You'll have to set up the same environment variables or configure the cloud credentials for Pulumi.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sparecores_runner-0.0.31.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sparecores_runner-0.0.31-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file sparecores_runner-0.0.31.tar.gz.

File metadata

  • Download URL: sparecores_runner-0.0.31.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sparecores_runner-0.0.31.tar.gz
Algorithm Hash digest
SHA256 5f9296a7aa5f2cee2a73c596f3df1efab88d6bbff1cda8eab834b1c9017eec46
MD5 94b26a11032808e3bf5c21f463bfe8ed
BLAKE2b-256 41427c9e1af07aeb926719761b871e9fb125bb216ce78030bc7e1ee615deef10

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparecores_runner-0.0.31.tar.gz:

Publisher: release.yml on SpareCores/sc-runner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparecores_runner-0.0.31-py3-none-any.whl.

File metadata

File hashes

Hashes for sparecores_runner-0.0.31-py3-none-any.whl
Algorithm Hash digest
SHA256 565b0bc8b3b2b76721bcf66401ff113921271e5754525c48ff0e454ecf4cc94c
MD5 27335438dc983bf39846c26bfb2e1657
BLAKE2b-256 33a4b5959866c4cefc1f7bafed8fa1acbef093fc6edc05d795b6a7c49f8da371

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparecores_runner-0.0.31-py3-none-any.whl:

Publisher: release.yml on SpareCores/sc-runner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page