Infra & Cloud
terraform
Beginner
DigitalOcean Droplet Terraform
Provision a DigitalOcean Droplet with SSH key and firewall via Terraform.
terraform
resource "digitalocean_droplet" "web" {
name = "web-01"
region = "nyc3"
size = "s-1vcpu-1gb"
image = "ubuntu-24-04-x64"
ssh_keys = [data.digitalocean_ssh_key.default.id]
}
resource "digitalocean_firewall" "web" {
name = "web-fw"
droplet_ids = [digitalocean_droplet.web.id]
inbound_rule { protocol = "tcp"; port_range = "443"; source_addresses = ["0.0.0.0/0"] }
outbound_rule { protocol = "tcp"; port_range = "all"; destination_addresses = ["0.0.0.0/0"] }
}
Prerequisites
- terraform >= 1.0
- digitalocean provider
Pro Tips
- → Use user_data to run cloud-init setup on first boot.
Commercial Licensing
Acquire a production access token or template license for enterprise deployment.
Module Info
- Language
- terraform
- Level
- Beginner
- Read time
- 4 min
- Published
- Dec 2025
- License
- Commercial License
Newsletter
New modules every week, directly to your inbox.
Similar Modules
AWS S3 Static Website
Terraform module to provision an S3 bucket for static website hosting.
terraform
·
Intermediate
AWS RDS Postgres Terraform
Terraform resource for an RDS PostgreSQL instance with encryption and backup.
terraform
·
Intermediate
ECS Task Force Stop
Force-stop all running ECS tasks in a service for emergency rollback.
bash
·
Intermediate