By dreawelabs
I have created a Rstudio droplet with a plumber API under the user ‘rtest’ at location ‘/home/test/api.R’. I have taken a snapshot of this droplet. Now I am trying to restore the droplet using digital ocean API and run the command to start the plumber API. The following steps need to be done to run the API:
How can I accomplish this? Or I need to do something else?
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!
Hello,
You could use the following request to generate your new Droplet:
curl -X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer $TOKEN' -d \
'{"name":"example.com","region":"nyc3","size":"512mb","image": 12345}' \
"https://api.digitalocean.com/v2/droplets"
You need to change the details so that they match your requirements, and also you need to change the image ID with your snapshot ID as well.
In case that you need to get your image ID, you can do it with this request:
- curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" "https://api.digitalocean.com/v2/images?page=1&per_page=1&private=true"
For more information, you can take a look at the official documentation here:
In case that you wanted to run some specific commands, you could also pass user data to your API request like this:
curl -X POST "https://api.digitalocean.com/v2/droplets" \
-d'{"name":"metadata.example.com","region":"nyc3","size":"s-1vcpu-1gb","vpc_uuid":"c33931f2-a26a-4e61-b85c-4e95a2ec431b","image":"ubuntu-20-04-x64","user_data":
"#!/bin/bash
apt-get -y update
apt-get -y install nginx
export HOSTNAME=$(curl -s http://169.254.169.254/metadata/v1/hostname)
export PUBLIC_IPV4=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)
echo Droplet: $HOSTNAME, IP Address: $PUBLIC_IPV4 > /usr/share/nginx/html/index.html",
"ssh_keys":[ < SSH KEY IDs > ]}' \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json"
For more information on user data you can take a look at the following documentation:
https://www.digitalocean.com/docs/droplets/how-to/provide-user-data/
Hope that this helps! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.