diff --git a/2024-09-25-cloudy.md b/2024-09-25-cloudy.md new file mode 100644 index 0000000..5a3f313 --- /dev/null +++ b/2024-09-25-cloudy.md @@ -0,0 +1,146 @@ +------------------------------------------------------ +title: Cloudy: CLI tool for easily spinning up compute instances in the cloud +summary: Run one-off compute instances in the cloud with an interface similar to Docker +tags: haskell +draft: false +------------------------------------------------------ + +I recently released a new CLI tool, +[Cloudy](https://github.com/cdepillabout/cloudy). Cloudy makes it easy to spin +up one-off compute instances using various cloud providers (like AWS, Scaleway, +etc). + +In practice, it feels similar to tools like `docker run` or `vagrant`, but for +running temporary compute instances in the cloud, instead of running locally. + +Cloudy gives a nice CLI interface (with good Bash completion) for interactively +managing your running compute instances. + +This post gives a brief overview of how to use Cloudy, and lays out my future +plans for the project. You can find out more information in the project's +[README](https://github.com/cdepillabout/cloudy/blob/master/README.md). + +## How to Use Cloudy + +Cloudy supports multiple cloud providers: + +- [AWS](https://aws.amazon.com/) ([support planned](https://github.com/cdepillabout/cloudy/issues/2)) +- [Scaleway](https://www.scaleway.com/) + +The following instructions assume you're using Scaleway. + +First, you'll need to setup a configuration file for Cloudy, as detailed +[in the README](https://github.com/cdepillabout/cloudy/blob/master/README.md#setup-for-scaleway). + +Once you've done that, you can create your first instance: + +```console +$ cloudy scaleway create \ + --zone nl-ams-1 \ + --instance-type PLAY2-NANO \ + --volume-size 75 \ + --image-id "1ec31ce3-bec3-4866-81fc-08d4b6966f9f" +``` + +This command creates a compute instance in Scaleway in zone +[`nl-ams-1`](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs/guides/regions_and_zones), +using instance type `PLAY2-NANO` (https://www.vpsbenchmarks.com/hosters/scaleway/plans/play2-nano), +with a 75 GB disk, and using an Ubuntu 24.04 disk image. + +After creating the image, you can SSH to it with the command: + +```console +$ cloudy ssh +``` + +When you're finished, you can shut it down with the command: + +```console +$ cloudy destroy +``` + +## Instance Setup Scripts + +One of the main features of Cloudy is the ability to specify Instance Setup +scripts. These are YAML files that contain cloud-init scripts to do things +like install packages and run commands on first boot. + +Here's an example of a Cloudy Instance Setup script: + +`~/.config/cloudy/instance-setups/hello-world.yaml`: + +```yaml +short-description: An example instance-setup script + +cloud-init-user-data: | + #cloud-config + + # Install these packages using the default package manager of the instance. + packages: + - cowsay + + # Run these commands after bootup. + runcmd: + - | + /usr/games/cowsay "hello world from Cloudy!" > /hello-from-cloudy +``` + +You can see that this script uses a cloud-init `cloud-config` file to install +the package `cowsay`, and then use it to print a message to the file +`/hello-from-cloudy` + +You can specify an Instance Setup script when creating a new instance: + +```console +$ cloudy scaleway create \ + --zone nl-ams-1 \ + --instance-type PLAY2-NANO \ + --volume-size 75 \ + --image-id "1ec31ce3-bec3-4866-81fc-08d4b6966f9f" \ + --instance-setup hello-world +``` + +Instance Setup scripts give you quite a lot of flexibility in how your compute +instances are setup. + +## Future Plans + +I have a few plans for future improvements to Cloudy: + +1. Support more cloud providers. + + It would be nice to support more cloud providers, like AWS, GCP, Azure, + DigitalOcean, etc. + + It would also be nice to make Cloudy flexible enough so that support for + additional cloud providers could be provided by plugins, similar to how + Terraform has plugins for different cloud providers. + +2. Provide more built-in Instance Setup scripts. + + Cloudy currently provides a few example Instance Setup scripts, but it + would be nice to provide additional scripts that do common tasks, like + setup popular web servers, databases, programming environments, etc. + +3. Add more functionality for operations to be performed after booting + an instance. + + It would be nice to add in support to Instance Setup scripts for doing + things like copying files back to the host after creating an instance, + running arbitrary commands on either the host or the cloud instance, etc. + + One use for this would be to copy files like public keys (after they are + generated) from the cloud instance to the local host. This would make + it easy to setup things like VPNs. + +4. Add the ability to specify input variables to Instance Setup scripts. + + I'm imagining this would work similarly to Terraform variables. + +## Conclusion + +Cloudy aims to be an easy-to-use imperative CLI tool for spinning up one-off +compute instances in various cloud providers. + +PRs and issues are welcome helping with any of the above features, or even just +fixing small bugs or making improvements.