aboutsummaryrefslogtreecommitdiff
path: root/terraform
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2023-10-23 14:41:22 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2023-10-23 14:41:22 +0200
commit3538a96392087c84af955772047b070fced8fccc (patch)
tree35e4b60de30ef93382fdc533a387c9a9e493d9a4 /terraform
parentf2a08300e11bc6040291ec12d4b78070f4bb94a0 (diff)
downloadinfra-3538a96392087c84af955772047b070fced8fccc.tar.gz
infra-3538a96392087c84af955772047b070fced8fccc.tar.bz2
infra-3538a96392087c84af955772047b070fced8fccc.tar.xz
infra-3538a96392087c84af955772047b070fced8fccc.zip
grafana
Diffstat (limited to 'terraform')
-rw-r--r--terraform/dns/vpn-cname.tf7
-rw-r--r--terraform/dns/vpn.tf2
-rw-r--r--terraform/grafana/.terraform.lock.hcl84
-rw-r--r--terraform/grafana/backend.tf12
-rw-r--r--terraform/grafana/grafana.tf48
-rw-r--r--terraform/grafana/main.tf39
-rw-r--r--terraform/grafana/pdb.tf13
-rw-r--r--terraform/grafana/terragrunt.hcl3
8 files changed, 207 insertions, 1 deletions
diff --git a/terraform/dns/vpn-cname.tf b/terraform/dns/vpn-cname.tf
index 5fc0b49..48dbbda 100644
--- a/terraform/dns/vpn-cname.tf
+++ b/terraform/dns/vpn-cname.tf
@@ -4,3 +4,10 @@ resource "linode_domain_record" "vpn-unifi" {
record_type = "CNAME"
target = "${linode_domain_record.vpn-conflatorio.name}.trygvis.io"
}
+
+resource "linode_domain_record" "vpn-grafana" {
+ domain_id = linode_domain.root.id
+ name = "grafana.vpn"
+ record_type = "CNAME"
+ target = "${linode_domain_record.vpn-conflatorio.name}.trygvis.io"
+}
diff --git a/terraform/dns/vpn.tf b/terraform/dns/vpn.tf
index 5ced457..4ed030b 100644
--- a/terraform/dns/vpn.tf
+++ b/terraform/dns/vpn.tf
@@ -15,7 +15,7 @@ resource "linode_domain_record" "vpn-conflatorio" {
domain_id = linode_domain.root.id
name = "conflatorio.vpn"
record_type = "AAAA"
- target = "fdf3:aad9:a885:0b3a::3"
+ target = "fdf3:aad9:a885:77dd::2"
}
resource "linode_domain_record" "vpn-arius" {
domain_id = linode_domain.root.id
diff --git a/terraform/grafana/.terraform.lock.hcl b/terraform/grafana/.terraform.lock.hcl
new file mode 100644
index 0000000..4362198
--- /dev/null
+++ b/terraform/grafana/.terraform.lock.hcl
@@ -0,0 +1,84 @@
+# This file is maintained automatically by "terraform init".
+# Manual edits may be lost in future updates.
+
+provider "registry.terraform.io/cyrilgdn/postgresql" {
+ version = "1.21.0"
+ constraints = "1.21.0"
+ hashes = [
+ "h1:v7X6z6j8Uo07+QJPuO3EVM8N1uy6t2k+1GiRGioOPGc=",
+ "zh:17e3d204dabc116276c763bb0cd159aa315789d3b0bcd3b8aede935509960ab6",
+ "zh:1a7e5ac1921afdb3b12a49714c5f446a7604bfa1eb7bd9c123d607f8cbda45e4",
+ "zh:24a880623e30928ee866c84016b1db4e0458764c7a547b808e2d398e90456d42",
+ "zh:255c6162d35ace6a313a50c4ceb5452bd5582d7bb097a44e75ac4901e635ca13",
+ "zh:281ab48b69d0852b5138fe5ea2301ff7fdff30748f1f7878ac837c71622d3f7b",
+ "zh:3d4e0ae2809e743272e5d2640b64354c48140e225c2ba6f1a211700ea70e0754",
+ "zh:4f4df290e3ff626d8b274c624852d21d194a397a7f580ebe0cbf0ff64dd8fa31",
+ "zh:5997ce8f7cbcd7ff5a443d037b83857b17b64be928e9d9338dd494466733df60",
+ "zh:a05f0b65b0abf4488cdaf7b239206940940be77fd51f458f2a0986c6a17436aa",
+ "zh:aeb6c6da639abb6126f38be90a7bc428f925461bf599388ff092e059e0bb1a94",
+ "zh:d30bb053b6000c32cc8d03da231c30eaecddd926200adf2e9ad9c0186c2ad1ad",
+ "zh:d978827683b324c75141fa80ebc28dcaf181acd0be0a47b1e5f9579a72a08151",
+ "zh:f51fae9206361cbe865e30b06d106270d6acf7ece0550953b0d6b55afe6be9ba",
+ "zh:fa49a2702c529865c20f57185d6dd41072fdd9a13ac1a49e30eb88605c31af7a",
+ ]
+}
+
+provider "registry.terraform.io/hashicorp/random" {
+ version = "3.5.1"
+ hashes = [
+ "h1:VSnd9ZIPyfKHOObuQCaKfnjIHRtR7qTw19Rz8tJxm+k=",
+ "zh:04e3fbd610cb52c1017d282531364b9c53ef72b6bc533acb2a90671957324a64",
+ "zh:119197103301ebaf7efb91df8f0b6e0dd31e6ff943d231af35ee1831c599188d",
+ "zh:4d2b219d09abf3b1bb4df93d399ed156cadd61f44ad3baf5cf2954df2fba0831",
+ "zh:6130bdde527587bbe2dcaa7150363e96dbc5250ea20154176d82bc69df5d4ce3",
+ "zh:6cc326cd4000f724d3086ee05587e7710f032f94fc9af35e96a386a1c6f2214f",
+ "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
+ "zh:b6d88e1d28cf2dfa24e9fdcc3efc77adcdc1c3c3b5c7ce503a423efbdd6de57b",
+ "zh:ba74c592622ecbcef9dc2a4d81ed321c4e44cddf7da799faa324da9bf52a22b2",
+ "zh:c7c5cde98fe4ef1143bd1b3ec5dc04baf0d4cc3ca2c5c7d40d17c0e9b2076865",
+ "zh:dac4bad52c940cd0dfc27893507c1e92393846b024c5a9db159a93c534a3da03",
+ "zh:de8febe2a2acd9ac454b844a4106ed295ae9520ef54dc8ed2faf29f12716b602",
+ "zh:eab0d0495e7e711cca367f7d4df6e322e6c562fc52151ec931176115b83ed014",
+ ]
+}
+
+provider "registry.terraform.io/kreuzwerker/docker" {
+ version = "2.24.0"
+ constraints = "2.24.0"
+ hashes = [
+ "h1:1z0/qA77T3PS/1m4vRO8UgWjHjk5/v+f3JfGbMyzX18=",
+ "zh:181fefd55c8eb75efe9815c43fdd76422b57951ef53b5d5f19273a00fdf0e2e2",
+ "zh:2ec84e029d169f188be2addf7f45c2555f226f67d4b6fb66c1749ed5b2c4a76a",
+ "zh:6f5cf945148485f57b919d31a30f1a5a93d45f4e8edfdb0b80b22258d51795d8",
+ "zh:8d00c2c459a48453f52a00a8d1ffdb7bcf72fe4b3b09ffcfd52218c4646fa7fa",
+ "zh:9bd6e06601e0a972b9ce01150e32e76b76b4caf1d9798daf4cf16d06e2a8d4a3",
+ "zh:af72591132dc8cd338f293e458403851e6b8a6ac4c4d25a3268940f9763df7aa",
+ "zh:c4a47c5c7ad2ff1fc5212e69c5ef837a127346264e46ce7b5d13362545e4aa70",
+ "zh:c6d68f33efcd3372331ed0d58ec49e8b01ddc132934b14d2d45977076950e4b3",
+ "zh:db228855ae7235095d367f3597719747e5be0dd9ce2206ea02062560b518c08a",
+ "zh:e8d6ce89642925f2e813d0b829bd5562582de37eaa39351e231ab474383e703a",
+ "zh:ec83d8c86a918d25eb824cc99f98924ef8949eb69aa40cb5ff2db24369e52d9c",
+ "zh:ee0032d3d86adeeca7fdd4922bb8db87dbb5cd0093c054ff8efe2260de0b624c",
+ "zh:f033b70f342f32eeb98c213e6fc7098d7afd22b3146a5cb6173c128b0e86d732",
+ "zh:f1bc3a2c4f152f8adc9a1f9c852496232ef31073b149945756c13bc9688cf08b",
+ ]
+}
+
+provider "registry.terraform.io/lokkersp/sops" {
+ version = "0.6.10"
+ constraints = "0.6.10"
+ hashes = [
+ "h1:atU8NIBxpNTWY+qBubvEOfjOn4K1aCDoq1iUFocgIHQ=",
+ "zh:0f053a26392a581b1f1ce6316cb7ed8ec4cc75e7f5f1cf7cfd45050b6b3c87ea",
+ "zh:207bb96c4471fce9aeb1b3c217d772692c3d865d294cf4d2501dad41de36a15e",
+ "zh:28506e8f1f3b9eaa95d99043440328044ee6340143535e5751538328a529d001",
+ "zh:3cae3bcea9e35fdc5b3f2af1b4580cd625c996448ad0c676c772260e46b25289",
+ "zh:3e44daaf82986c2b0028aeb17b867f3c68ed5dd8ac8625ba0406cf2a5fd3d92e",
+ "zh:457fb8ca2e677af24f9a4bdd8b613b1d7b604ad7133541657e5757c19268da71",
+ "zh:473d727c228f021a3df8cc8dcc6231ad7f90ed63f9e47c36b597d591e76228da",
+ "zh:48c4c1df39fd76ec8bd5fe9ac70cdc0927ac8be95582dbe46458b3442ce0fcd9",
+ "zh:728b19cb5c07e5e9d8b78fd94cc57d4c13582ecd24b7eb7c4cc2bf73b12fe4d1",
+ "zh:c51ed9af591779bb0910b82addeebb10f53428b994f8db653dd1dedcec60916c",
+ "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c",
+ ]
+}
diff --git a/terraform/grafana/backend.tf b/terraform/grafana/backend.tf
new file mode 100644
index 0000000..e796c2e
--- /dev/null
+++ b/terraform/grafana/backend.tf
@@ -0,0 +1,12 @@
+# Generated by Terragrunt. Sig: nIlQXj57tbuaRZEa
+terraform {
+ backend "s3" {
+ bucket = "terraform-a6726272-73ff-11ed-8bdd-c79eb8376e05"
+ key = "grafana/terraform.tfstate"
+ skip_region_validation = true
+ skip_credentials_validation = true
+ skip_metadata_api_check = true
+ region = "eu-central-1"
+ endpoint = "eu-central-1.linodeobjects.com"
+ }
+}
diff --git a/terraform/grafana/grafana.tf b/terraform/grafana/grafana.tf
new file mode 100644
index 0000000..d72d457
--- /dev/null
+++ b/terraform/grafana/grafana.tf
@@ -0,0 +1,48 @@
+data "docker_network" "traefik" {
+ name = "traefik"
+}
+
+resource "docker_image" "grafana" {
+ name = "grafana/grafana-oss:10.1.5"
+}
+
+resource "docker_volume" "grafana" {
+ name = "grafana"
+}
+
+resource "docker_container" "grafana" {
+ image = docker_image.grafana.image_id
+ name = "grafana"
+ privileged = false
+ must_run = true
+
+ networks_advanced {
+ name = data.docker_network.traefik.name
+ }
+
+ dynamic "labels" {
+ for_each = [
+ { label = "traefik.enable", value = "true" },
+ { label = "traefik.http.routers.grafana.rule", value = "Host(`grafana.vpn.trygvis.io`)" },
+ { label = "traefik.http.routers.grafana.entrypoints", value = "websecure" },
+ { label = "traefik.http.routers.grafana.tls.certresolver", value = "linode" },
+ ]
+ content {
+ label = labels.value["label"]
+ value = labels.value["value"]
+ }
+ }
+
+ env = [
+ "GF_DATABASE_TYPE=postgres",
+ "GF_DATABASE_HOST=[fdf3:aad9:a885:b3a::1]",
+ "GF_DATABASE_DATABASE=${postgresql_database.grafana.name}",
+ "GF_DATABASE_USER=${postgresql_role.grafana.name}",
+ "GF_DATABASE_PASSWORD=${postgresql_role.grafana.password}",
+ ]
+
+ volumes {
+ volume_name = docker_volume.grafana.name
+ container_path = "/var/lib/grafana"
+ }
+}
diff --git a/terraform/grafana/main.tf b/terraform/grafana/main.tf
new file mode 100644
index 0000000..d27c60e
--- /dev/null
+++ b/terraform/grafana/main.tf
@@ -0,0 +1,39 @@
+terraform {
+ required_version = "~> 1.3.5"
+
+ required_providers {
+ docker = {
+ source = "kreuzwerker/docker"
+ version = "2.24.0"
+ }
+ postgresql = {
+ source = "cyrilgdn/postgresql"
+ version = "1.21.0"
+ }
+ random = {
+ source = "hashicorp/random"
+ version = "3.5.1"
+ }
+ sops = {
+ source = "lokkersp/sops"
+ version = "0.6.10"
+ }
+ }
+}
+
+provider "docker" {
+ host = "ssh://conflatorio.vpn.trygvis.io"
+}
+
+data "sops_file_entry" "knot_pdb_terraform_password" {
+ source_file = "../../sops.yml"
+ data_key = "knot_pdb_terraform_password"
+}
+
+provider "postgresql" {
+ host = "knot.vpn.trygvis.io"
+ database = "postgres"
+ username = "terraform"
+ password = data.sops_file_entry.knot_pdb_terraform_password.data
+ sslmode = "require"
+}
diff --git a/terraform/grafana/pdb.tf b/terraform/grafana/pdb.tf
new file mode 100644
index 0000000..e2a59cd
--- /dev/null
+++ b/terraform/grafana/pdb.tf
@@ -0,0 +1,13 @@
+resource "random_uuid" "grafana_password" {
+}
+
+resource "postgresql_role" "grafana" {
+ name = "grafana"
+ login = true
+ password = random_uuid.grafana_password.result
+}
+
+resource "postgresql_database" "grafana" {
+ name = "grafana"
+ owner = "grafana"
+}
diff --git a/terraform/grafana/terragrunt.hcl b/terraform/grafana/terragrunt.hcl
new file mode 100644
index 0000000..e147285
--- /dev/null
+++ b/terraform/grafana/terragrunt.hcl
@@ -0,0 +1,3 @@
+include "root" {
+ path = find_in_parent_folders()
+}