Skip to main content

Vultr Deployment Playbook

Vultr Deployment Playbook

This guide demonstrates common Vultr API operations for managing virtual machine instances via the Vultr API.

Prerequisites

Whitelist your IP

You must whitelist your IP address with Vultr.

  1. Go to the Vultr Settings API dashboard

  2. Retrieve your 32 bit IPV4 address by running this on your host machine:

    curl ifconfig.me
  3. Update the Access Control list with {IPv4_OUTPUT_ABOVE}/32 and click Add.

Screenshot Example

Image

API Key

Obtain your API key from my.vultr.com/settings/#settingsapi

export VULTR_API_KEY="your-api-key-here"
IP Whitelist

Managing Instances

Creating an Instance

Update command

Make sure to replace the following placeholders:

  • YOUR_INSTANCE_NAME
  • YOUR_HOST_NAME
  • Optionally, list of tags

The command below creates a new instance with the following parameters:

  • plan vc2-6c-16gb: 6 vCPUs w/ 16GB RAM and 320GB SSD
  • os_id 2136: Debian 12 x64
  • region sea: Seattle, WA, USA
curl "https://api.vultr.com/v2/instances" \
-X POST \
-H "Authorization: Bearer ${VULTR_API_KEY}" \
-H "Content-Type: application/json" \
--data '{
"region" : "sea",
"plan" : "vc2-6c-16gb",
"label" : "YOUR_INSTANCE_NAME",
"os_id" : 2136,
"backups" : "disabled",
"hostname": "YOUR_HOST_NAME",
"tags": ["personal", "test", "cli", "YOUR_HOST_NAME"]
}' \
> vultr_create.json

Get Instance Details

VULTR_INSTANCE_ID=$(cat vultr_create.json | jq -r '.instance.id')

curl "https://api.vultr.com/v2/instances/${VULTR_INSTANCE_ID}" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}" \
> vultr_get.json

echo "###\nVisit your instance at https://my.vultr.com/subs/?id=${VULTR_INSTANCE_ID} \n###\n"

Environment Setup

Once you've created and retrieved your instance details, you can set up your environment variables for easier management.

export VULTR_INSTANCE_ID=$(cat vultr_create.json | jq -r '.instance.id')
export VULTR_INSTANCE_IP=$(cat vultr_get.json | jq -r '.instance.main_ip')
export VULTR_PASSWORD=$(cat vultr_create.json | jq -r '.instance.default_password')

Connect to Your Instance

Connect to your instance:

ssh root@$VULTR_INSTANCE_IP

Password is in vultr_create.json under instance.default_password. To copy password to clipboard:

cat vultr_create.json | jq -r '.instance.default_password' | pbcopy

Delete Instance

curl "https://api.vultr.com/v2/instances/${VULTR_INSTANCE_ID}" \
-X DELETE \
-H "Authorization: Bearer ${VULTR_API_KEY}"

[OPTIONAL] Exploring Available Resources

List Available Plans

Get the list of available plans:

curl "https://api.vultr.com/v2/plans" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}" \
> vultr_plans.json

And explore the JSON by running:

cat vultr_plans.json | jq

List Available Operating Systems

Get the list of available operating systems:

curl "https://api.vultr.com/v2/os" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}" \
> vultr_os.json

And explore the JSON by running:

cat vultr_os.json | jq

Additional Resources