1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
terraform {
  required_providers {
    linode = {
      source  = "linode/linode"
      version = "1.30.0"
    }

    http = {
      source  = "hashicorp/http"
      version = "3.2.1"
    }
  }
}

variable "domain" {
  type     = string
  nullable = false
}

data "http" "github_keys" {
  url = "https://github.com/kejadlen.keys"
}

resource "linode_instance" "lotus_land_story" {
  label           = "lotus-land-story"
  image           = "linode/debian11"
  region          = "us-west"
  type            = "g6-nanode-1"
  authorized_keys = split("\n", chomp(data.http.github_keys.response_body))
  backups_enabled = true
}

resource "linode_volume" "lotus_land_story" {
  label     = "lotus-land-story"
  region    = "us-west"
  linode_id = linode_instance.lotus_land_story.id
  size      = 10

  connection {
    host = resource.linode_instance.lotus_land_story.ip_address
  }

  provisioner "remote-exec" {
    inline = [
      "mkfs.ext4 '${self.filesystem_path}'",
      "mkdir '/mnt/lotus-land-story'",
      "mount '${self.filesystem_path}' '/mnt/lotus-land-story'",
    ]
  }
}

data "linode_domain" "domain" {
  domain = var.domain
}

resource "linode_domain_record" "subdomains" {
  domain_id   = data.linode_domain.domain.id
  record_type = "A"
  target      = resource.linode_instance.lotus_land_story.ip_address

  for_each = toset([
    "auth",
  ])
  name = each.key
}

output "lotus_land_story_ip" {
  value = resource.linode_instance.lotus_land_story.ip_address
}

output "lotus_land_story_volume" {
  value = resource.linode_volume.lotus_land_story.filesystem_path
}