Terraform + Multi Repo Setup

Description → One Repo → Multiple Branch → One Droplet → Multiple Domain
First Script → Setup our project Environment
Second Script → Run Project

Download Terraform
Extract zip file
→ run terraform.exe
check terraform version
terraform --version

Download terraform code from here


Create API Tokens in Digital Ocean
Go to and log in to your account.
Generate a New Token
Name the Token
Expiration :- 30/60/90 days and No Expire
Set Permissions :- full access
Screenshot 2024-09-18 171244.png

Go to AWS Console
go to security credentials
image.png

Go to Users
image.png

Create access key
image.png
image.png

Create Access key
image.png
Copy Access Key & Secret Access Key

Secret Name
Go to secret Manager → select Secret
Store a new Secret
image.png

add env in key pair values or plaintext that support json format
image.png

add name
image.png

Click Next
image.png

Store the Secret
image.png

env-test →secret_name
image.png

Create terraform.tfvars file

do_token = "" #API TOKEN
ssh_public_key_path = "" #public_key_path
ssh_private_key_path = ""#private_key_path
droplet_image = "ubuntu-24-04-x64"
droplet_name = "web-server" #droplet_name
droplet_region = "blr1"
droplet_size = "s-1vcpu-1gb"
aws_access_key = " " #access_key
aws_secret_key = "" #secret_key
aws_region = "us-east-1" # region
node_version = "18"
dragonfly_repo = "git@github.com:owner/repo_name.git" #repo name
dragonfly_port = port of dragonfly
dragonfly_domain = "" # Domain name
dragonfly_secret = "" #secret name
dragonfly_branch = "" #branch name
firefly_repo = "git@github.com:owner/repo_name.git" #repo name
firefly_port = port of firefly
firefly_domain = "" # Domain name
firefly_secret = "" #secret name
firefly_branch = "" #branch name

Save the file
→ Open Terminal in that Folder
terraform init

terraform plan

apply → Create Droplet Server & install dependencies
terraform apply

Run repo name wise


Run Dragonfly
Start Dragonfly
terraform apply -var="app_action=setup_dragonfly"
Destroy Dragonfly
terraform apply -var="app_action=destroy_dragonfly"


Run Firefly
Start Dragonfly
terraform apply -var="app_action=setup_firefly"
Destroy Dragonfly
terraform apply -var="app_action=destroy_firefly"
This link can't be embedded.
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.