Terraform configuration for provisioning a DigitalOcean droplet. Uses cloud-init to bootstrap the server on first boot, including installation of the sysinfo CLI tool.
- Terraform >= 1.5.0
- DigitalOcean account with an API token
- SSH key registered in your DigitalOcean account
terraform-digital-ocean/
├── main.tf # Provider, SSH key lookup, droplet resource
├── variables.tf # Input variables
├── outputs.tf # Droplet IP, ID, SSH command
├── cloud-init.yaml # First boot provisioning script
├── terraform.tfvars # Your values — never commit this
└── .gitignore
1. Clone the repo
git clone https://github.com/zemation/terraform-digital-ocean.git
cd terraform-digital-ocean2. Create your tfvars file
cp terraform.tfvars.example terraform.tfvarsEdit terraform.tfvars with your values:
do_token = "YOUR_DIGITALOCEAN_API_TOKEN"
ssh_key_name = "YOUR_KEY_NAME"
droplet_name = "server-zemation"
droplet_image = "ubuntu-24-04-x64"
droplet_size = "s-1vcpu-1gb"
region = "nyc3"
sysinfo_version = "v1.0.0"3. Deploy
terraform init
terraform plan
terraform apply4. Connect
After apply completes, Terraform outputs the SSH command:
ssh_command = "ssh root@<droplet_ip>"
5. Destroy
terraform destroyOn first boot cloud-init runs and installs:
| Tool | Version | Location |
|---|---|---|
| sysinfo | Configurable via sysinfo_version |
/usr/local/bin/sysinfo |
| Name | Description | Default |
|---|---|---|
do_token |
DigitalOcean API token | required |
ssh_key_name |
SSH key name registered in DO | zemation |
droplet_name |
Name for the droplet | server-zemation |
droplet_image |
OS image slug | ubuntu-24-04-x64 |
droplet_size |
Droplet size slug | s-1vcpu-1gb |
region |
DigitalOcean region | nyc3 |
sysinfo_version |
sysinfo release tag to install | v1.0.0 |
| Name | Description |
|---|---|
droplet_ip |
Public IP address |
droplet_id |
DigitalOcean droplet ID |
droplet_name |
Droplet name |
droplet_region |
Deployed region |
ssh_command |
Ready-to-run SSH command |
terraform.tfvarsis gitignored — never commit your API tokenssh_key_nameis case sensitive and must match exactly what is stored in DigitalOcean- cloud-init runs once on first boot — to re-run provisioning destroy and reapply