Report this

What is the reason for this report?

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

Posted on April 17, 2021
yaz

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



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.

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

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)

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.