This repository contains Terraform code to automate the setup of servers using DigitalOcean.
Before you can use this Terraform configuration, make sure you have the following:
- DigitalOcean account connected to your credit card.
- Your own domain.
- Terraform CLI installed on your machine.
- Clone this repository to your local machine.
- Update the terraform.tfvars file with your DigitalOcean API token or use the -var CLI option to pass the token.
- Run terraform init to initialize the working directory and download the necessary provider plugins.
- Run terraform plan to see the execution plan and ensure everything is set up correctly.
- If the plan looks good, run terraform apply and confirm by typing "yes" when prompted.
- Terraform will create a new DigitalOcean Droplet based on the specified configuration.
- Once the Droplet is created, you can access it via its public IP address or your configured domain.
If you want to customize the Droplet configuration, you can modify the main.tf file. Here are a few options you can change:
image
: The operating system image used for the Droplet. You can find available options in the DigitalOcean API documentation.name
: The name of the Droplet.region
: The region where the Droplet will be deployed.size
: The size of the Droplet in terms of CPU and memory.
To destroy the created Droplet and clean up the resources, run terraform destroy
and confirm by typing "yes" when prompted. This will remove the server and associated resources from DigitalOcean.
Note: Be cautious when using terraform destroy as it permanently deletes the resources. Make sure you have backed up any important data.