Question

How to automatically verify that resize action is finished and turn on droplet

  • Posted on April 17, 2021
  • API
  • yaz1979Asked by yaz

Hello I am looking for a bash script that allows me to resize the droplet and start it after the operation is finished. I was able to handle the resize with API using curl in my bash script

curl -X POST -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer EXAMPLE947b217efb6f3ec3bdEXAMPLE' \
     -d '{"type":"resize","size":"s-2vcpu-4gb"}' \
    "https://api.digitalocean.com/v2/droplets/droplet_id/actions"

but seems that turning on the droplet is not done automatically after the action is finished


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @yaz1979,

In my experience, you can use one of the following

  • List All Actions for a Volume To retrieve all actions that have been executed on a volume, send a GET request to /v2/volumes/$VOLUME_ID/actions. The results will be returned as a JSON object with an actions key. This will be set to an array filled with action objects containing the standard volume action attributes:

Or better yet, this one:

  • Retrieve an Existing Volume Action - To retrieve the status of a volume action, send a GET request to /v2/volumes/$VOLUME_ID/actions/$ACTION_ID. The response will be an object with a key called action. The value of this will be an object that contains the standard volume action attributes:

I would suggest the latter would be a better option - Retrieve an Existing Volume Action

You can read more about them here:

* [List All Actions for a Volume- 
 API](https://developers.digitalocean.com/documentation/v2/#list-all-actions-for-a-volume)

* [Retrieve an Existing Volume Action - API](https://developers.digitalocean.com/documentation/v2/#retrieve-an-existing-volume-action)

Hello,

You can check the API Documentation for Turning ON a droplet:

https://developers.digitalocean.com/documentation/v2/#power-on-a-droplet

A curl example is the following snippet:

  1. curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer b7d03a6947b217efb6f3ec3bd3504582" -d '{"type":"power_on"}' "https://api.digitalocean.com/v2/droplets/3164450/actions"

Regards, Alex