Question

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

Posted April 17, 2021 75 views
API

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

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.

×
Submit an Answer
2 answers

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:

  • 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

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/$VOLUMEID/actions/$ACTIONID. 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: