Deploy a DigitalOcean Droplet with Terraform
Learn Infrastructure as Code basics by deploying a simple web server on DigitalOcean using Terraform. Perfect for beginners starting their IaC journey.
- DigitalOcean account (free trial available)
- Terraform installed (v1.0+)
- Basic command line knowledge
- Text editor (VS Code, vim, etc.)
- Understand Infrastructure as Code fundamentals
- Learn Terraform workflow (init, plan, apply, destroy)
- Deploy and manage cloud resources programmatically
- Configure basic web server infrastructure
- Work with Terraform state and outputs
Prerequisites and Initial Setup
Set up your local environment and create a DigitalOcean API token for Terraform authentication.
Configure Terraform Provider
Create the main Terraform configuration file and configure the DigitalOcean provider.
Create SSH Key Resource
Generate an SSH key pair and upload the public key to DigitalOcean for secure droplet access.
Define Droplet Resource
Create the main droplet resource with basic configuration and cloud-init user data.
Configure Terraform Outputs
Define output values to display the droplet's IP address and access URL.
Test and Verify Deployment
Verify that the web server is accessible and functioning correctly.
Explore Terraform State
Learn about Terraform state management and inspect the current state.
Modify Infrastructure
Learn how to update existing infrastructure by modifying Terraform configuration.
Clean Up Resources
Destroy all created resources to avoid unnecessary charges. Learn the importance of cleanup.
Found an issue?
More exercises
Linux
Creating and Connecting to Your First Linux Server
Spin up an Ubuntu 24.04 Linux server in the cloud, configure SSH key authentication, and learn to navigate your new server. This exercise uses DigitalOcean but the steps work with any cloud provider.
30 minutes
Terraform
AWS VPC with Terraform
Build a complete AWS VPC infrastructure using Terraform with public/private subnets, NAT gateway, and security groups.
120 minutes
Git
Git Workflow and Collaboration Fundamentals
Master essential Git workflows, branching strategies, and collaboration techniques used in modern development teams.
50 minutes
Also worth your time on this topic
Terraform Infrastructure as Code Best Practices
Terraform best practices for writing scalable, maintainable infrastructure as code - covering directory structure, state management, modules, and security.
Terraform Repository Structure Checklist
Best practices for organizing and structuring your Terraform projects for maintainability and scalability.
30-45 minutes
Creating and Connecting to Your First Linux Server
Spin up an Ubuntu 24.04 Linux server in the cloud, configure SSH key authentication, and learn to navigate your new server. This exercise uses DigitalOcean but the steps work with any cloud provider.
30 minutes