Skip to content

nilukush/brightlyst_infrastructure

Repository files navigation

DigitalOcean Terraform Configuration for Brightlyst

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.

Project Overview

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.

Prerequisites

  • 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.

Installation & Setup

  1. Install Terraform: Ensure you have Terraform installed. Download Terraform and follow the installation instructions for your operating system.

  2. Clone the Repository: Clone this repository to your local machine:

    git clone --recurse-submodules [email protected]:nilukush/brightlyst_infrastructure.git
    cd brightlyst-infrastructure
  3. 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.

  4. Initialize Terraform: Run Terraform's init command to prepare your project for deployment:

    terraform init
  5. 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.

Database Setup

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 a local-exec provisioner that executes MySQL commands.

Prerequisites for Database Setup

  • MySQL CLI Tool: Installed for manual database operations.
  • doctl: Installed for managing DigitalOcean resources directly if needed.

Manual Steps

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]"

Managing Infrastructure

  • 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.

Security

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.

Support & Contributing

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.

License

This project is open-sourced under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published