This commit is contained in:
Tommy Parnell
2022-06-22 20:27:04 -04:00
parent 67bd122144
commit 4ebe5fd413
4 changed files with 24 additions and 15 deletions

View File

@@ -39,6 +39,6 @@ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo apt-key
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
sudo echo "ide.terrible.dev \
sudo echo "${dns_name} \
reverse_proxy 127.0.0.1:8080" > /etc/caddy/Caddyfile
sudo systemctl reload caddy

18
main.tf
View File

@@ -1,14 +1,18 @@
resource "digitalocean_droplet" "web" {
image = "ubuntu-20-04-x64"
name = "web-1"
region = "nyc1"
size = "s-1vcpu-1gb-amd"
ssh_keys = var.ssh_keys
user_data = "${file("deploy-vm/launch-code-server.sh")}"
image = "ubuntu-20-04-x64"
name = "web-1"
region = "nyc1"
size = "s-1vcpu-1gb-amd"
ssh_keys = var.ssh_keys
user_data = templatefile("deploy-vm/launch-code-server.sh", { dns_name = "${var.dns_name}.${cloudflare_zone.main_zone.name}" })
}
data "cloudflare_zone" "main_zone" {
zone_id = var.cloudflare_zone
}
resource "cloudflare_record" "droplet" {
zone_id = var.cloudflare_zone
zone_id = cloudflare_zone.main_zone.id
name = "ide"
value = digitalocean_droplet.web.ipv4_address
type = "A"

View File

@@ -1,7 +1,7 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
cloudflare = {
@@ -19,6 +19,6 @@ provider "digitalocean" {
}
provider "cloudflare" {
email = var.cloudflare_email
email = var.cloudflare_email
api_token = var.cloudflare_api_token
}

View File

@@ -1,17 +1,22 @@
variable "do_token" {
type = string
type = string
}
variable "cloudflare_email" {
type = string
type = string
}
variable "cloudflare_api_token" {
type = string
type = string
}
variable "cloudflare_zone" {
type = string
type = string
}
variable "ssh_keys" {
type = list(string)
type = list(string)
}
variable "dns_name" {
type = string
default = "ide"
}