Digitalocean Cloud Command Line Introduction

tthtlc 12 views 13 slides Jun 29, 2024
Slide 1
Slide 1 of 13
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13

About This Presentation

Here is a brief introduction to using the digitalocean via the command line interface.


Slide Content

Digitalocean Cloud Command Line Peter Teoh

Two ways for Digitalocean command line doctl: https://docs.digitalocean.com/reference/doctl/how-to/install/ HTTP API: https://docs.digitalocean.com/reference/api/ But actually a few other methods exists: https://docs.digitalocean.com/reference/

doctl https://docs.digitalocean.com/reference/doctl/how-to/install/

doctl examples Install sudo snap install doctl # Linux Authenticate doctl doctl auth init List Droplets doctl compute droplet list Create a Droplet doctl compute droplet create my-droplet --size s-1vcpu-1gb --image ubuntu-20-04-x64 --region nyc1 Delete a Droplet doctl compute droplet delete DROPLET_ID Retrieve Information About a Droplet doctl compute droplet get DROPLET_ID List Domains doctl compute domain list

doctl examples (II) Create a Domain doctl compute domain create example.com --ip-address DROPLET_IP Delete a Domain doctl compute domain delete example.com List DNS Records doctl compute domain records list example.com Create a DNS Record doctl compute domain records create example.com --record-type A --record-name www --record-data DROPLET_IP Delete a DNS Record doctl compute domain records delete example.com RECORD_ID List SSH Keys doctl compute ssh-key list Add an SSH Key doctl compute ssh-key import --public-key-file ~/.ssh/id_rsa.pub --name my-key Delete an SSH Key doctl compute ssh-key delete SSH_KEY_ID List Images doctl compute image list Retrieve Information About an Image doctl compute image get IMAGE_ID Delete an Image doctl compute image delete IMAGE_ID List Sizes doctl compute size list List Regions doctl compute region list List Volumes doctl compute volume list Create a Volume doctl compute volume create --region nyc1 --size 10GiB --name my-volume Attach a Volume to a Droplet doctl compute volume-action attach VOLUME_ID DROPLET_ID Detach a Volume from a Droplet doctl compute volume-action detach VOLUME_ID Resize a Volume doctl compute volume resize VOLUME_ID --size 20GiB Delete a Volume doctl compute volume delete VOLUME_ID List Snapshots doctl compute snapshot list Create a Snapshot of a Droplet doctl compute droplet snapshot DROPLET_ID --snapshot-name my-snapshot Delete a Snapshot doctl compute snapshot delete SNAPSHOT_ID Retrieve Account Information doctl account get

Billing Listing

First step: create the Personal Access Token

HTTP API + Shell script: calling API via the PAT #!/bin/bash # Personal Access Token (PAT) TOKEN="xxxxx" # API Endpoint API_ENDPOINT="https://api.digitalocean.com/v2" # v2/customers/my/balance curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" "$API_ENDPOINT/ customers/my/balance " | jq curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" "$API_ENDPOINT/ customers/my/billing_history " | jq

Billing

Droplets Calling the

Billing

Droplets related