Create Snapshot with API and identifying it later
So I want to create a Snapshot from a Droplet and then create a new Droplet from said Snapshot (and delete the old Droplet once I confirmed that it is working as expected).
The whole point in doing so is to change the IP address of the Droplet.
Technically it is not a problem but it involves some horrible looping which I really can’t make a “while True”.
Once I created the snapshot via
/v2/droplets/$DROPLET_ID/actions, the response doesn’t tell me how to identify the snapshot once it has been created but solely the action id.
I could of course request
/v2/actions/$ACTION_ID until the status is not “in-progress” but this wouldn’t help much. So what I do is requesting
/v2/snapshots up to 10 times with a
sleep(30) (Python) in between and hoping to identify the droplet by name.
Drawbacks are of course endless. Has anyone done something similar with a better approach?
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.×