aboutsummaryrefslogtreecommitdiff
path: root/vps.tf
diff options
context:
space:
mode:
Diffstat (limited to 'vps.tf')
-rw-r--r--vps.tf78
1 files changed, 50 insertions, 28 deletions
diff --git a/vps.tf b/vps.tf
index 701c98d..badc698 100644
--- a/vps.tf
+++ b/vps.tf
@@ -1,9 +1,22 @@
-variable "floating_ip" {}
+variable "do_token" {
+ type = "string"
+ description = "DigitalOcean API token."
+}
+
+variable "tld" {
+ type = "string"
+ description = "Root Top-Level Domain. Subdomains will be derived from it."
+}
-variable "do_token" {}
-variable "tld" {}
-variable "wallabag_tld" {}
-variable "nextcloud_tld" {}
+variable "wallabag_tld_prefix" {
+ type = "string"
+ description = "DNS prefix used for the Wallabag installation. Does not contain a dot at the end."
+}
+
+variable "nextcloud_tld_prefix" {
+ type = "string"
+ description = "DNS prefix used for the Nextcloud installation. Does not contain a dot at the end."
+}
provider "digitalocean" {
token = "${var.do_token}"
@@ -42,11 +55,6 @@ resource "digitalocean_droplet" "vps" {
}
}
-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"
@@ -60,26 +68,40 @@ resource "digitalocean_volume_attachment" "foobar" {
droplet_id = "${digitalocean_droplet.vps.id}"
}
-locals {
- cname_subdomains = [
- "${var.wallabag_tld}",
- "${var.nextcloud_tld}",
- ]
+resource "digitalocean_floating_ip" "vps_public_ip" {
+ region = "${digitalocean_droplet.vps.region}"
}
-resource "godaddy_domain_record" "vps_tld" {
- domain = "${var.tld}"
- addresses = ["${var.floating_ip}"]
+resource "digitalocean_floating_ip_assignment" "vps_public_ip_assignment" {
+ ip_address = "${digitalocean_floating_ip.vps_public_ip.id}"
+ droplet_id = "${digitalocean_droplet.vps.id}"
+}
- record {
- type = "CNAME"
- name = "${var.tld}"
- data = "${var.wallabag_tld}"
- }
+output "public_floating_ip" {
+ value = "${digitalocean_floating_ip.vps_public_ip.ip_address}"
+}
- record {
- type = "CNAME"
- name = "${var.tld}"
- data = "${var.nextcloud_tld}"
- }
+resource "digitalocean_domain" "vps_tld" {
+ name = "${var.tld}"
+}
+
+resource "digitalocean_record" "at_sign" {
+ domain = "${digitalocean_domain.vps_tld.name}"
+ type = "A"
+ name = "@"
+ value = "${digitalocean_floating_ip.vps_public_ip.ip_address}"
+}
+
+resource "digitalocean_record" "wallabag" {
+ domain = "${digitalocean_domain.vps_tld.name}"
+ type = "CNAME"
+ name = "${var.wallabag_tld_prefix}"
+ value = "${digitalocean_domain.vps_tld.name}."
+}
+
+resource "digitalocean_record" "nextcloud" {
+ domain = "${digitalocean_domain.vps_tld.name}"
+ type = "CNAME"
+ name = "${var.nextcloud_tld_prefix}"
+ value = "${digitalocean_domain.vps_tld.name}."
}