Skip to content

Spin up a hello world droplet running docker using Terraform

License

Notifications You must be signed in to change notification settings

dills122/do-terraform-docker

Repository files navigation

Example Digital Ocean Droplet With Docker

DO Slugs: https://slugs.do-api.dev/

Getting Started

You will need to have terraform installed to start.

Env Vars you need to ensure are set so that terraform can work.

TF_VAR_do_token='Digitial_Ocean_token'
TF_VAR_ssh_key_fingerprint='ssh fingerprint in DO console'
# downloads provider and sets up the dir
terraform init

# creates a plan based off the configuration setup
terraform plan -out droplet_volume.tfplan

# execute the created plan and deploy
terraform apply "droplet_volume.tfplan"

# clean up
terraform destroy

Then once its finished you should be able to navigate to the ip address listed in the console.

SSH

A script is included that you can use to setup your SSH key, you can call it like:

SSH into the newly created droplet with your new SSH key

ssh root@IP_ADDRESS -i ~/.ssh/do_id_rsa.pub

FYIs

Windows

If you are trying to use powershell you will need to setup the env vars so powershell can recognize them. More here

Resources