Skip to content

tobimadehin/playground

Repository files navigation

Playground

CI NPM Version License: MIT

Playground lets you launch, manage, and clean up cloud instances across multiple providers. The playground itself is stateless, so you choose how to track instances.

Quick Start

  1. Install the package
npm install @tobimadehin/playground
  1. Create a provider map
import { AWSProvider, Playground } from '@tobimadehin/playground';

const providers = new Map();
providers.set('aws', new AWSProvider({ 
  accessKeyId: '...', 
  secretAccessKey: '...', 
  region: 'us-east-1' 
}));

const playground = new Playground({ 
  providers,
  imageMappingsPath: './examples/image-mappings.yaml'
});
  1. Launch an instance
const instance = await playground.createInstance({
  imageType: 'ubuntu-22-small',
  sshKey: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB... user@host'
});

console.log('Instance created:', instance.id, instance.ip);
  1. Track and clean up
import { PlaygroundUtils } from '@tobimadehin/playground';

if (PlaygroundUtils.isExpired(instance)) {
  await playground.destroyInstance(instance.provider, instance.id);
}

Next Steps

License

MIT License — see LICENSE for details.