For spinning up an Ubuntu VM in Digital Ocean really fast!
git clone https://github.com/garrett-ts/fast-droplet.git
cd fast-droplet
You can do so on MacOS with homebrew:
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
This will be required for Terraform to create the VM via the Digital Ocean API. How to create a personal access token
Copy your token, and set it as an environment variable.
export TF_VAR_DIGITALOCEAN_TOKEN='paste_token_here'
This is required in order to access the VM. This step only needs to be done once. How to create SSH keys
Once the key is generated, make note of its location and use the appropriate curl command.
If you have a new SSH key that hasn't been added to your account:
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TF_VAR_DIGITALOCEAN_TOKEN" \
-d '{"name":"your_name_here","public_key":"paste the public key's contents here"}' \
"https://api.digitalocean.com/v2/account/keys"
If you have an existing SSH key and need the ID:
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TF_VAR_DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/account/keys" | jq '.'
In either command, make note of the ID in the curl output. It must be set as an environment variable.
export TF_VAR_SSH_KEY='paste_key_id_here'
terraform init
terraform plan
terraform apply
Confirm the terraform commands with yes
.
If successful, the output of the terraform apply
command will include the public IP of the VM. Use that with your provided SSH key to access it.
ssh -i 'path/to/ssh_key' root@vm_ip_address