-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
loki.tf
61 lines (47 loc) · 1.63 KB
/
loki.tf
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
// https://github.com/grafana/loki/tree/main/production/helm/loki
# S3 Bucket
resource "aws_s3_bucket" "s3_loki" {
count = var.grafana_loki_enabled ? 1 : 0
bucket = var.grafana_loki_bucket_name
}
# Block public access to the S3 bucket
resource "aws_s3_bucket_public_access_block" "s3_loki" {
count = var.grafana_loki_enabled ? 1 : 0
bucket = join("", aws_s3_bucket.s3_loki.*.id)
block_public_acls = true
block_public_policy = true
}
# Enable default encryption for the S3 bucket using a customer-managed key
resource "aws_s3_bucket_server_side_encryption_configuration" "s3_loki" {
count = var.grafana_loki_enabled ? 1 : 0
bucket = join("", aws_s3_bucket.s3_loki.*.id)
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
# Enable versioning for the S3 bucket
resource "aws_s3_bucket_versioning" "s3_loki" {
count = var.grafana_loki_enabled ? 1 : 0
bucket = join("", aws_s3_bucket.s3_loki.*.id)
versioning_configuration {
status = "Enabled"
}
}
resource "helm_release" "loki" {
count = var.grafana_loki_enabled ? 1 : 0
chart = "loki"
name = "loki"
namespace = "loki"
create_namespace = true
repository = "https://grafana.github.io/helm-charts"
version = "6.10.2"
values = [
var.grafana_loki_yml_file != null ? var.grafana_loki_yml_file : templatefile("${path.module}/loki.yml", {
s3_bucket = join("", aws_s3_bucket.s3_loki.*.bucket),
s3_bucket_region = join("", aws_s3_bucket.s3_loki.*.region),
storage_class = var.storage_class
}),
]
}