variable "floating_ip" {} variable "do_token" {} variable "tld" {} variable "wallabag_tld" {} variable "nextcloud_tld" {} provider "digitalocean" { token = "${var.do_token}" version = "~> 1.1" } resource "digitalocean_ssh_key" "client" { name = "terraform-vps-client" public_key = "${file("${path.module}/secrets/ssh/vps-box-client.pub")}" } resource "digitalocean_droplet" "vps" { image = "ubuntu-18-04-x64" name = "sovereignty" region = "nyc3" size = "s-1vcpu-1gb" backups = true ipv6 = true monitoring = true user_data = "${file("${path.module}/user-data.sh")}" ssh_keys = [ "${digitalocean_ssh_key.client.fingerprint}", ] connection { user = "root" type = "ssh" private_key = "${file("${path.module}/secrets/ssh/vps-box-client")}" timeout = "2m" } provisioner "remote-exec" { inline = ["echo 'SSH is up! Noop remote-exec is done.'"] } } resource "digitalocean_floating_ip_assignment" "vps" { ip_address = "${var.floating_ip}" droplet_id = "${digitalocean_droplet.vps.id}" } resource "digitalocean_volume" "vps_persistent_volume" { region = "nyc3" name = "vps-persistent-volume" size = 10 initial_filesystem_type = "ext4" description = "Persistent disk to store docker volumes contents across droplets being created and destroyed" } resource "digitalocean_volume_attachment" "foobar" { volume_id = "${digitalocean_volume.vps_persistent_volume.id}" droplet_id = "${digitalocean_droplet.vps.id}" } locals { cname_subdomains = [ "${var.wallabag_tld}", "${var.nextcloud_tld}", ] } resource "godaddy_domain_record" "vps_tld" { domain = "${var.tld}" addresses = ["${var.floating_ip}"] record { type = "CNAME" name = "${var.tld}" data = "${var.wallabag_tld}" } record { type = "CNAME" name = "${var.tld}" data = "${var.nextcloud_tld}" } }