Report this

What is the reason for this report?

Invoke a script or command using after creating a droplet

Posted on December 12, 2017

When using the DigitalOcean API to create a new droplet, is there a way to have the droplet run a command or script once it spins (using the API)?

Thanks.



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.

you specify it in the user-data tab, your droplet will run cloud-init on boot, and you can specify your script should only run once. You can do loads of stuff in your cloud-init config

Hi @alastairc, thanks for replying.

Just a few more questions

you specify it in the user-data tab,

Where do I find the user-data tab?

Can those be built by using the DO API as well (i.e. built programmatically)?

Thanks!

You can also send user-data via the API populating the user-data field in your request to the create endpoint.

Exactly what I was looking for!

Thank you @ryanpq

And also thanks @alastairc for your suggestions as well.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.