Is there a means to create a droplet with a cost limit?
Suppose I am building a service on top of Digital Ocean droplets, and I want to purchase some free trial time for users. Lets say I want to create droplets on their behalf to run a service in a sandboxed manner.
Is there a way to set a limit on a droplet’s cost use. EG, I want to create a droplet but not have it spend more than 10 cents. If it reaches 10 cents, it auto-destroys.
I want to have a guarantee that a malicious user or mistake will not accidentally burn a bunch of cash.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
This isn’t something that is possible by default – you’d have to bake this in to your application.
When a Droplet is created using the API, you’ll receive a JSON object as a response and within it, you can pull created_at, which is described as:
A time value given in ISO8601 combined date and time format that represents when the Droplet was created
To get the total time that a Droplet has been active, you’d simply get the different between the current time and the one provided by created_at. You’d then compare that against however long you allow them to use the service for free and if it meets or exceeds, issue a destroy command.
https://developers.digitalocean.com/documentation/v2/#create-a-new-droplet
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
