This repository contains the Terraform configuration files for provisioning infrastructure resources on DigitalOcean for the Brightlyst project. It's designed to create a secure, scalable, and highly available environment for deploying a web application.
The Brightlyst Terraform project automates the deployment of a DigitalOcean Droplet within a Virtual Private Cloud (VPC), ensuring secure and isolated network traffic. It also sets up SSH access for secure remote management of the Droplet.
- DigitalOcean Account: You need an account on DigitalOcean. Sign up here if you haven't already.
- DigitalOcean Personal Access Token: Required for Terraform to authenticate with the DigitalOcean API. Generate a token here.
- SSH Key: An SSH key added to your DigitalOcean account for secure access to your Droplets. Instructions here.
-
Install Terraform: Ensure you have Terraform installed. Download Terraform and follow the installation instructions for your operating system.
-
Clone the Repository: Clone this repository to your local machine:
git clone --recurse-submodules [email protected]:nilukush/brightlyst_infrastructure.git cd brightlyst-infrastructure
-
Configuration: Configure your project by editing the
terraform.tfvars
file with your DigitalOcean personal access token, SSH key fingerprint, and other customizable variables:do_token = "your_digitalocean_personal_access_token" region = "nyc3" image = "ubuntu-20-04-x64" size = "s-1vcpu-1gb" ssh_fingerprint = "your_ssh_key_fingerprint"
Note: Do not commit
terraform.tfvars
to version control to keep your secrets secure. -
Initialize Terraform: Run Terraform's
init
command to prepare your project for deployment:terraform init
-
Deploy Infrastructure: Preview the changes Terraform will make with the
plan
command and apply the changes to provision your DigitalOcean infrastructure:terraform plan terraform apply
Confirm the action at the prompt, and Terraform will begin provisioning your resources.
This project includes configuration for setting up a MySQL database brightlyst
and a table brightlyst_linkedin
required for the application:
- Automated Database Creation: The database is automatically created through Terraform using the
mysql_database
resource. - Table Setup: Tables are set up using a
null_resource
with alocal-exec
provisioner that executes MySQL commands.
- MySQL CLI Tool: Installed for manual database operations.
doctl
: Installed for managing DigitalOcean resources directly if needed.
For manual database or table setup, use the following command template, replacing placeholders with your actual values:
mysql --host=[HOSTNAME] --port=25060 --user=[USERNAME] --password=[PASSWORD] --ssl-ca=[PATH_TO_CA_CERTIFICATE] -e "[SQL_COMMAND]"
- View Infrastructure: Check the current state of your infrastructure using
terraform show
. - Update Infrastructure: Modify your configuration files and run
terraform apply
to update your infrastructure. - Destroy Infrastructure: Remove all the infrastructure resources managed by Terraform with
terraform destroy
.
Ensure your terraform.tfvars
and any .tfstate
files are excluded from version control by including them in your .gitignore
file. Manage secrets securely and consider using a secrets manager for sensitive information.
For support, contact the project maintainers or submit an issue on the GitHub repository issue tracker. Contributions to this project are welcome! Please fork the repository and submit a pull request with your proposed changes.
This project is open-sourced under the MIT License. See the LICENSE file for details.