cloud.nix/main.tf

56 lines
1.2 KiB
HCL

variable "do_token" {}
provider "digitalocean" {
token = var.do_token
}
data "digitalocean_ssh_key" "terraform" {
name = "terraform"
}
resource "digitalocean_droplet" "main" {
image = "debian-10-x64"
name = "main"
region = "nyc3"
size = "s-4vcpu-8gb"
private_networking = true
user_data = file("nixos_infect.yaml")
ssh_keys = [
data.digitalocean_ssh_key.terraform.id
]
}
resource "digitalocean_volume" "storage" {
region = "nyc3"
name = "storage"
size = 1000
initial_filesystem_type = "ext4"
description = "main storage volume"
}
resource "digitalocean_volume_attachment" "storage" {
droplet_id = digitalocean_droplet.main.id
volume_id = digitalocean_volume.storage.id
}
# DOMAINS
resource "digitalocean_domain" "default" {
name = "samhatfield.me"
}
resource "digitalocean_record" "www" {
domain = digitalocean_domain.default.name
type = "A"
name = "@"
value = digitalocean_droplet.main.ipv4_address
}
# GITHUB PAGES
resource "digitalocean_record" "neuron" {
domain = digitalocean_domain.default.name
type = "CNAME"
name = "neuron"
value = "sehqlr.github.io."
}