Skip to content

pgrabarczyk/digitalocean-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

digitalocean-example

Requirements

Before first run

# https://github.com/tfutils/tfenv
tfenv install
terrafom version
# https://docs.digitalocean.com/reference/doctl/how-to/install/
doctl auth init --context <NAME>
doctl auth switch --context <NAME>
doctl account get
DIGITALOCEAN_ACCESS_TOKEN=$(cat $HOME/.config/doctl/config.yaml | grep "private:" | cut -d' ' -f4)
export DIGITALOCEAN_ACCESS_TOKEN=$DIGITALOCEAN_ACCESS_TOKEN
 
# Below should generate service_key_do & service_key_do.pub
ssh-keygen -t rsa -C "[email protected]" -f "./service_key_do"

# Load public key to DO
doctl compute ssh-key import "service_key_do" --public-key-file "service_key_do.pub"

Run

Create infra

# cd infra/envs/dev/
terraform init
terraform plan -var "do_token=$DIGITALOCEAN_ACCESS_TOKEN" -out ".terraform.plan.out"
terraform apply ".terraform.plan.out"

SSH into ubuntu droplet

# SSH into new machine
IP_ADDRESS=$(terraform output | cut -d'"' -f2)
ssh terraform@$IP_ADDRESS -i "../../../service_key_do"

# Note. Apache2 server may be down / configuring for ~3minutes after terraform apply

Destroy infra

terraform destroy -var "do_token=$DIGITALOCEAN_ACCESS_TOKEN"

Helpful links:

https://learn.hashicorp.com/tutorials/terraform/digitalocean-provider?in=terraform/applications https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs https://www.w3schools.com/w3css/w3css_templates.asp https://docs.digitalocean.com/reference/doctl/reference/compute/region/list/

TODO

  • Setup LoadBalancer
  • Hide droplets into private network
  • Setup DNS for LoadBalancer
  • Draw diagram
  • Setup DB and connect services with DB via private networks

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published